Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Amplify GraphQL Schema that is linked to Cognito User Pool

I am using the AWS Amplify to create a website platform that functions mostly as a directory of its registered users with various attributes relating to the business domain. The two primary users for the platform will be registered users and normal unauthenticated users who will be able to list and filter the registered users based on their attributes such as location, age, etc. Registered users will be set all their attributes in the members area.

Some of the attributes are stored in Cognito such as name and address and were setup using Amplify Authentication. These are fields I would like to be to query and mutate through the Amplify GraphQL capabilities.

I can see there are cool authorization patterns that can be achieved with the @auth directive.

Is it possible to leverage GraphQL Transform such that I can create a model schema where some of the fields link to the Cognito User Pool and some are defined within the GraphQL schema so that they are queryable and mutable? In fact I would like to provide registered users with the facility to update all their fields except email. Or maybe there is some combination of services supported by Amplify that I can hook up together to achieve the same?

I am new to the AWS Serveless ecosystem and it has been exciting so far!

like image 215
tony Avatar asked Dec 11 '19 22:12

tony


1 Answers

I found out the above can be achieved using the @function directive. It allows us to connect lambda resolvers to the schema. In the lambda we can do virtually anything like read and update Amazon Cognito User Pools.

https://aws-amplify.github.io/docs/cli-toolchain/graphql#function

like image 198
tony Avatar answered Oct 10 '22 04:10

tony