Skip to content

ServerlessReact.dev

Student Login

Upsert users when they login

We start with an example that's mostly handled for us by Auth0, but is still a good way to talk about the basics. You most often want to have the concept of a user in your own database too.

Prepare GraphQL mutation

Mutation resolver

Create DynamoDB table

Here you'll see me copy paste a dynamodb.ts file from an older project. After reviewing this step I decided to open source that file as a library and recommend you install that instead.

# in <project>/server
yarn add simple-dynamodb

First working test of your resolver

Write mutation to actually upsert

Verify upserting users works

Running mutation in useMutation

Extract logic into custom hooks

How useAuth and useUpdateUser work together

Created bySwizecwith ❤️