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

Nested imported fragments can give false positives on unique-fragment-name #507

Closed
lennartbuit opened this issue Jun 29, 2021 · 4 comments · Fixed by #511
Closed

Nested imported fragments can give false positives on unique-fragment-name #507

lennartbuit opened this issue Jun 29, 2021 · 4 comments · Fixed by #511
Labels
stage/5-alpha-release-testing The pull request is merged, an alpha release is available, to be tested

Comments

@lennartbuit
Copy link

lennartbuit commented Jun 29, 2021

Describe the bug

When a query imports a fragment (using #import) that itself also imports another fragment, all documents are reported as to having a duplicate fragment names.

To Reproduce

Check out this gist: https://gist.github.com/lennartbuit/3d0141b62432c133ca553de15792ad17

In this setup, I have a query importing fragment A that itself imports fragment B.

Running yarn eslint *.graphql will flag all files as having violations of the unique-fragment-name rule:

Screenshot 2021-06-29 at 21 35 30

Expected behavior

No reported errors. Fragments are only defined once, after all.

Environment:

  • OS: Mac OS
  • @graphql-eslint/...: 1.1.0
  • NodeJS: v14.16.1

Additional context

@lennartbuit
Copy link
Author

[I can spin this out in a seperate issue if you'd like] The @graphql-eslint/no-unused-fragments also doesn't handle this situation of nested imports correctly:

Screenshot 2021-06-29 at 23 56 06

I would have expected fragments to be considered used if they were imported by imports of intermediate fragments.

@dimaMachina
Copy link
Contributor

Thank you @lennartbuit your description is very helpful, we'll fix this very soon!

@dotansimha dotansimha reopened this Jul 4, 2021
@dotansimha dotansimha added stage/5-alpha-release-testing The pull request is merged, an alpha release is available, to be tested and removed stage/1-reproduction A reproduction exists labels Jul 4, 2021
@dotansimha
Copy link
Member

Fixed in @graphql-eslint/eslint-plugin@1.1.1

@lennartbuit
Copy link
Author

lennartbuit commented Jul 5, 2021

Thank you both! Checked with my original codebase and confirmed fixed these issue[s] there as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/5-alpha-release-testing The pull request is merged, an alpha release is available, to be tested
3 participants