hasura / learn-graphql

Real world GraphQL tutorials for frontend developers with deadlines!
https://hasura.io/learn/
MIT License
1.19k stars 647 forks source link

Add missing step to nextjs-auth.md #945

Closed embiem closed 1 year ago

embiem commented 1 year ago

Adds missing step to create the object relationship accounts.userId -> users.id.

Description

While following the guide I was running into this issue:

https://next-auth.js.org/errors#adapter_error_getuserbyaccount field 'accounts' not found in type: 'users_bool_exp': {"response":{"errors":[{"extensions":{"code":"validation-failed","path":"$.selectionSet.users.args.where.accounts"},"message":"field 'accounts' not found in type: 'users_bool_exp'"}]

It was solved by adding the object relationship as mentioned.

Steps to test and verify

Use the guide with current versions and try to login. It will throw the above error.

After adding the object relationship it will work, as it adds the necessary accounts field to the GetUsers query.

praveenweb commented 1 year ago

Hi, @embiem. Thanks for the PR.

What was the GraphQL query that you were trying to execute? Is it part of this guide? I'm unable to see the usage of accounts in the query example. Happy to merge with the right context.

embiem commented 1 year ago

@praveenweb hey. I wasn't running any query in particular, just the next-auth library as detailed in that guide. When trying to login it'd throw the error as next-auth depends on the accounts.userId -> users.id relationship to exist.

I can double check to make sure.