Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

naming-convention rule should not fail when aliasing __typename #2430

Open
4 tasks
Eynorey opened this issue Jul 3, 2024 · 0 comments
Open
4 tasks

naming-convention rule should not fail when aliasing __typename #2430

Eynorey opened this issue Jul 3, 2024 · 0 comments

Comments

@Eynorey
Copy link

Eynorey commented Jul 3, 2024

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox

    For example, you can start off by editng the
    'basic' example on Stackblitz.

    Please make sure the graphql-eslint version under package.json matches yours.

  • 2. A failing test has been provided

  • 3. A local solution has been provided

  • 4. A pull request is pending review


Describe the bug

This is a follow-up to #664.

While querying __typename is allowed now, assigning an alias to that field still causes a linting error if allowLeadingUnderscore is false:

error   Leading underscores are not allowed   @graphql-eslint/naming-convention

To Reproduce Steps to reproduce the behavior:

Define a query like this:

const GET_USER = `
  query {
    user {
      type: __typename
      name
    }
  }
`;

And it fails validation for the aliased __typename field.
This works fine when we're not using an alias:

const GET_USER = `
  query {
    user {
      __typename
      name
    }
  }
`;

Expected behavior

Querying the __typename field should also be allowed if we're aliasing the field name.

Environment:

  • OS: Ubuntu 22.04.4 LTS
  • @graphql-eslint/eslint-plugin: v3.20.1`
  • Node.js: v20.12.2

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant