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 ?

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠