#✅ - amplify graphql query

4 messages · Page 1 of 1 (latest)

untold pollen
#

I have this query:

export const queryUserById = async (id: string) => { let result = await API.graphql<GraphQLQuery<GetUserQuery>>( graphqlOperation(getUser, { id, } as GetUserQueryVariables, ) ) return result.data.getUser }
The problem is, when i query another user, it says "Not Authorized to access customer_number on type User" and it throws an error.
This is my schema for it:

customer_number: String @auth( rules: [ { allow: owner, operations: [read, create] } { allow: public, provider: apiKey } ] )

How do i avoid this error? The field is null how its supposed to be

hallow jewel
#

when you call getUser are you doing that from a user authenticated in cognito, or are you using the apiKey (if so how are you setting it)?

worthy holly
hallow bearBOT
#

✅ - amplify graphql query