How to get the current user from a Lambda resolver in AWS Amplify (GraphQL api and NodeJS Lambda)?

Viewed 321

I have a graphql Api and added a lambda function to resolve a mutation.

type Mutation {
  addTeamMember(email: String!, teamId:ID!): String @function(name: "add-team-member-${env}")
}

From the lambda I want to retrieve the authenticated user that sent the request to perform additional validations, ¿How to retrieve it from the request information?

strong text

1 Answers

I printed the contents of the first lambda parameter and found it:

Access it with:

event.identity.username
Related