gyurisc
gyurisc

Reputation: 11502

NextAuth+Hasura: `field 'accounts' not found in type: 'users_bool_exp'

I am trying to follow the nextauth hasura tutorial, but I am getting the following error:

message: `field 'accounts' not found in type: 'users_bool_exp':
POST /api/auth/signin/github 302 in 8ms
[next-auth][error][adapter_error_getUserByAccount] 
https://next-auth.js.org/errors#adapter_error_getuserbyaccount field 'accounts' not found in type: 'users_bool_exp': {"response":{"errors":[{"message":"field 'accounts' not found in type: 'users_bool_exp'","extensions":{"path":"$.selectionSet.users.args.where.accounts","code":"validation-failed"}}],"status":200,"headers":{}},"request":{"query":"query GetUsers($where: users_bool_exp!) {\n  users(where: $where) {\n    ...User\n  }\n}\n\nfragment User on users {\n  __typename\n  id\n  name\n  email\n  image\n  emailVerified\n}","variables":{"where":{"accounts":{"provider":{"_eq":"github"},"providerAccountId":{"_eq":"790821"}}}}}}

Looking at the callstack shows that the error is coming from the hasura adapter

    '    at makeRequest (\\node_modules\\graphql-request\\build\\cjs\\index.js:310:15)\n' +
    '    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +
    '    at async getUserByAccount (\\node_modules\\next-auth-hasura-adapter\\dist\\index.js:46:25)',
  name: 'Error'

I am new to nextauth and hasura and looking for tips on resolving this. All help is appreciated.

Upvotes: 0

Views: 68

Answers (1)

gyurisc
gyurisc

Reputation: 11502

I found the answer in issues section of the next-auth-hasura-adapter github repo . I was missing a relationship in my hasura schema between users.id and sessions.userId.

Here is the link to the issue: Github Issue

Upvotes: 0

Related Questions