1

I'm developing an app that should have a schedule date to users. Let's say that it's a soccer match.

So it would have:

  • id
  • full date
  • players

The "players" itself are all users that must authenticate using the standard AWS Amplify authentication and of course are enrolled in the game. I want to be able to retrieve all the players (email, username) who is in a match. I am about to do the graphql API model to the match entity. How am I suppose to map the one-to-many players from the AWS Authentication?

Should I just map the fields that I want (email, username) or is there any kind of direct relationship that I can use to retrieve the user object? like search by an id.

1 Answer 1

1

Perhaps you create a "database user" and save the ID to Cognito as custom user attributes, which allows you to fetch the user information from there at a later point:

// On Signup
const { data } = await API.graphql(graphqlOperation(createUser, {input: user}));
await Auth.updateUserAttributes(cognitoUser, {'custom:dbuserid': data.createUser.id});

// On Signin
const cognitoUser = await Auth.signIn({ username: rusername, password: rpassword })
const { data } = await API.graphql(graphqlOperation(getUser, {id: cognitoUser.attributes["custom:dbuserid"] }));

Or you save all your user information to Cognito as custom user attributes, but I believe there is a max of 50, which could be a limit for you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.