Amplify Graphql list only current user Todo's

Viewed 673

Having a schema.graphql like this one:

type Todo @model @auth(rules: [
  {
    allow: owner,
    operations: [create, read, update, delete],
    identityClaim: "sub"
  }
]) {
  id: ID!
  name: String!
  description: String
  owner: String
}

I have cognito for athentication working on my test app. I can create users, log in as one of them, etc.

What doeas @auth directive exactly? When I use my listTodos query:

const todoData = await API.graphql(graphqlOperation(listTodos));

I expect to have back from the server only my todos, but I got all of them. Obviously I'm missing something out.

I mean, If I view my table data, the owner field is correctly popullated with my user's ID.

How do I accomplish my use case? Listing only my items

0 Answers
Related