Populate fields from identity claims.
npm install --save graphql-claim-transformer
Edit amplify/backend/api/<YOUR_API>/transform.conf.json
and append "graphql-claim-transformer"
to the transformers
field.
"transformers": [
"graphql-claim-transformer"
]
Append @claim
to target fields.
type Todo @model {
id: ID!
title: String!
description: String
foo: String @claim(name: "bar")
}
In the above example the create and update mutations will set the foo
field to the value of the bar
claim on the user identity object ($ctx.identity.claims.get("bar")
).