Amplify mock api weird results in explorer/app

0

Dependencies: node 18.14.2 amplify/cli 10.6.2

Used auth: Default Auth: Cognito UserPool Second: API Key

User A is in cognito group "admin" User B is **not ** in any group

Graphql schema

type Test
  @model
  @auth(
    rules: [
      # Allow client to read the item
      { allow: owner, 
        provider: userPools, 
        ownerField: "client", 
        identityClaim: "sub", 
        operations: [read] },
      # Allow admin users to access any operation
      { allow: groups, groups: ["admin"] }
    ]
  ) {
  id: ID!
  name: String
  client: String
}

App code

      const res = await API.graphql<GraphQLQuery<ListTestQuery>>({
        query: queries.listTest,
        authMode: GRAPHQL_AUTH_MODE.AMAZON_COGNITO_USER_POOLS,
      });

Expected result: User A gets a list of all entries. User B only gets only items that have his "sub" as client string

Actual behavior: I get different results with the same query in local testing within the explorer and my app. In the mock explorer everything works as intended if i switch users.

GraphQL Explorer:

  • User A gets all items -> Good
  • User B only gets matching items -> Good

App:

  • User A gets all items -> Good
  • User B gets an empty array -> Bad

Question:

Why do i get different results between the app and the Graphql Explorer ?

沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南