nextauthjs / next-auth

Authentication for the Web.
https://authjs.dev
ISC License
24.31k stars 3.39k forks source link

Hasura Adapter incompatible with GraphQL Naming Convention #8951

Closed Californian closed 11 months ago

Californian commented 11 months ago

Adapter type

@auth/hasura-adapter

Environment

System:
  OS: Linux 6.5 Arch Linux
Binaries:
  Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
  npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm

Reproduction URL

NA

Describe the issue

Hasura has historically used the default, non-JS-standard, snake_case naming convention. Somewhat recently, they added support for standard graphql naming conventions for queries etc: https://hasura.io/docs/latest/schema/postgres/naming-convention/

The hasura adapter should support this standard graphql naming convention with an option in the config.

{
  query: [String (TypedDocumentString): '\n' +
    '    query GetUsers($where: users_bool_exp!) {\n' +
    '  users(where: $where) {\n' +
    '    ...User\n' +
    '  }\n' +
    '}\n' +
    '    fragment User on users {\n' +
    '  id\n' +
    '  name\n' +
    '  email\n' +
    '  image\n' +
    '  emailVerified\n' +
    '}'] {
    value: '\n' +
      '    query GetUsers($where: users_bool_exp!) {\n' +
      '  users(where: $where) {\n' +
      '    ...User\n' +
      '  }\n' +
      '}\n' +
      '    fragment User on users {\n' +
      '  id\n' +
      '  name\n' +
      '  email\n' +
      '  image\n' +
      '  emailVerified\n' +
      '}',
    __meta__: undefined
  },
  variables: { where: { accounts: [Object] } }
}
[auth][error][AdapterError]: Read more at https://errors.authjs.dev#adaptererror
[auth][cause]: HasuraClientError: variable 'where' is declared as 'users_bool_exp!', but used where 'UsersBoolExp' is expected
    at Object.run (webpack-internal:///(rsc)/./node_modules/@auth/hasura-adapter/lib/client.js:33:39)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getUserByAccount (webpack-internal:///(rsc)/./node_modules/@auth/hasura-adapter/index.js:148:31)
    at async acc.<computed> (webpack-internal:///(rsc)/./node_modules/@auth/core/lib/init.js:157:24)
    at async Module.callback (webpack-internal:///(rsc)/./node_modules/@auth/core/lib/routes/callback.js:58:39)
    at async AuthInternal (webpack-internal:///(rsc)/./node_modules/@auth/core/lib/index.js:104:38)
    at async Auth (webpack-internal:///(rsc)/./node_modules/@auth/core/index.js:121:30)
    at async /home/chicago-maximum/eaglecorps/social-app/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:62499
[auth][details]: {}
[auth][error][AdapterError]: Read more at https://errors.authjs.dev#adaptererror
[auth][cause]: HasuraClientError: variable 'where' is declared as 'users_bool_exp!', but used where 'UsersBoolExp' is expected
    at Object.run (webpack-internal:///(rsc)/./node_modules/@auth/hasura-adapter/lib/client.js:33:39)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getUserByAccount (webpack-internal:///(rsc)/./node_modules/@auth/hasura-adapter/index.js:148:31)
    at async acc.<computed> (webpack-internal:///(rsc)/./node_modules/@auth/core/lib/init.js:157:24)
    at async Module.callback (webpack-internal:///(rsc)/./node_modules/@auth/core/lib/routes/callback.js:58:39)
    at async AuthInternal (webpack-internal:///(rsc)/./node_modules/@auth/core/lib/index.js:104:38)
    at async Auth (webpack-internal:///(rsc)/./node_modules/@auth/core/index.js:121:30)
    at async /home/chicago-maximum/eaglecorps/social-app/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:62499
[auth][details]: {
  "provider": "google"
}

How to reproduce

Create new hasura project, follow the steps here to enable graphql naming convention: https://hasura.io/docs/latest/schema/postgres/naming-convention/

Create a nextjs/authjs project with the hasura adapter and add credentials for the above hasura instance.

Attempt to log in.

Expected behavior

User should be signed in and data persisted to the database.

github-actions[bot] commented 11 months ago

We could not detect a valid reproduction link. Make sure to follow the bug report template carefully.

Why was this issue closed?

To be able to investigate, we need access to a reproduction to identify what triggered the issue. We need a link to a public GitHub repository. Example: (NextAuth.js example repository).

The bug template that you filled out has a section called "Reproduction URL", which is where you should provide the link to the reproduction.

What should I do?

Depending on the reason the issue was closed, you can do the following:

In general, assume that we should not go through a lengthy onboarding process at your company code only to be able to verify an issue.

My repository is private and cannot make it public

In most cases, a private repo will not be a sufficient minimal reproduction, as this codebase might contain a lot of unrelated parts that would make our investigation take longer. Please do not make it public. Instead, create a new repository using the templates above, adding the relevant code to reproduce the issue. Common things to look out for:

I did not open this issue, but it is relevant to me, what can I do to help?

Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps by opening a new issue.

I think my reproduction is good enough, why aren't you looking into it quickly?

We look into every issue and monitor open issues for new comments.

However, sometimes we might miss a few due to the popularity/high traffic of the repository. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.

Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.

Useful Resources