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

errors for require-id-when-available with nested fragments occurring in wrong place #1866

Open
4 tasks
danielchiu opened this issue Sep 12, 2023 · 0 comments
Open
4 tasks

Comments

@danielchiu
Copy link

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

Sometimes require-id-when-available issues are flagged on line 0:0, and when this happens the error cannot be ignored (neither eslint-disable-next-line nor eslint-disable work).

lint: /path/to/file/1
lint:   0:0  error  Field `intensityTimeseries.id` must be selected when it's available on a type.
lint: Include it in your selection set or add to used fragments `TrajectoryFields` or `SimpleTimeseriesFields`                                                                                             @graphql-eslint/require-id-when-available

To Reproduce Steps to reproduce the behavior:

I'm not totally sure when it happens, but I believe it may be when there's a fragment used which is defined in another file and itself uses a fragment violating the rule.

/path/to/file/1

query {
  field {
    ...Fields
  }
}

/path/to/file/2

fragment SimpleTimeseriesFields {
  # no id
  name
  value
}

fragment Fields on Field {
  id
  intensityTimeseries {
    ...SimpleTimeseriesFields
  }
}

Expected behavior

The error should appear on the line using the offending fragment, rather than on line "0". And as such, it should be ignorable.

Environment:

  • OS: MacOS
  • @graphql-eslint/eslint-plugin: 3.19.1
  • Node.js: 18.15.3

Additional context

Would love any pointers to the potential cause, and any workarounds! Currently, the workaround is excluding the files in the eslint config.

@danielchiu danielchiu changed the title require-id-when-available errors for require-id-when-available with nested fragments occurring in wrong place Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant