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

Multi-project configurations cannot be linted all at once #2260

Open
1 of 4 tasks
benasher44 opened this issue Apr 22, 2024 · 2 comments
Open
1 of 4 tasks

Multi-project configurations cannot be linted all at once #2260

benasher44 opened this issue Apr 22, 2024 · 2 comments

Comments

@benasher44
Copy link

benasher44 commented Apr 22, 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

The lint plugin does load per-project schemas, but it loads it once and ends up reusing it for all files. This results in using one project's schema to lint schemas of other projects.

To Reproduce Steps to reproduce the behavior:

  1. Configure multi-project graphql files setup (e.g. src/project1//*.graphql, src/project2//*.graphql)
  2. Run lint for the whole folder

Expected behavior

Lint should pass, but it instead claims that (for example) types are unreachable, since it's checking those types against the project that was loaded for the lint pass.

Environment:

  • OS: macOS
  • @graphql-eslint/eslint-plugin: 3.20.1
  • Node.js:

Additional context

Having looked at the code a little bit, it looks like each rule looks at the loaded schema, which will be the schema loaded by the plugin at the start of the lint pass. Instead, each rule should reuse the code that loads the schema from the project-specific schema cache.

@benasher44
Copy link
Author

Maybe this is a FlatConfig-specific thing? I can't reproduce this in the example project, but I can definitely reproduce it in ours.

@benasher44
Copy link
Author

benasher44 commented Apr 22, 2024

Confirmed this reproduces in the multiple-project sample project. It doesn't reproduce today because both schemas define a User type. If you just change one of them to be called AdminUser instead, it reproduces:

image

This will say that the AdminUser is unreachable, if eslint loads the other schema first.

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