AWS Amplify GraphQL Query without knowing the ID

Viewed 9

I want to run a query that fetches a specific user. As the id of the user is auto-generated on creation, I cant figure out a way to know what user has what ID without pulling in all the users and then finding the id of that user - that defeats the point in just querying 1 user.

Here is the schema:

type Users @model @auth(rules: [{allow: public}]) {
  email: AWSEmail!
  access_token: String
  refresh_token: String
  company: String
  role: String
}

The query I need to use is:

query MyQuery {
  getUsers(id: "") {
    email
    id
    refresh_token
    role
    company
    access_token
  }
}

The query asks for the id, but I wont know what the id is, so is there a way to use email? Also if I wanted to update a specific user (by there email address) how could I do that?

I hope this question makes sense, this is the first time I am using graphQL so I'm still trying to get my head around it.

Thank you

0 Answers
Related