-
Notifications
You must be signed in to change notification settings - Fork 106
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
Fragments are not properly detected for the known-fragment-names
rule
#472
Comments
Hi @jgoux, please provide a sample repo and not output in |
Closing due to inactivity. Please feel free to reopen if you still need help. |
Sorry for taking so long! 😅 Here is the minimal repro : https://github.com/jgoux/graphql-eslint-repro You need to run It's still present on the last release I don't see any option to reopen the issue. |
Hi @jgoux and thank you for the report Sorry but I'm not adding a lot here but just labeling it according to our new Contribution Guide and issue flow. It seems already got into Now in order to advance to Thank you and sorry that this comment is not a complete solution (yet). |
@jgoux I don’t see import comment in your file https://github.com/jgoux/graphql-eslint-repro/blob/main/src/UserProfileScreen.graphql can you add |
@B2o5T Indeed, it works with the A couple of things :
|
I just discovered this great project and had the same experience as @jgoux. From reading the docs I assumed the |
I also agree with the above. Just added it to my project and it's amazing. The only downside is that I have to disable those 2 rules around Fragments, cause I don't want to add unnecessary |
Happy to see that I'm not the only one surprised by the behaviour with fragments and imports. 😄 Is it possible to have a clear answer to my first point @dotansimha ?
Is it a bug or the expected behaviour? As we don't have auto-completion on graphql imports and no refactoring tools, it's pretty complicated to have the right paths for the fragments files (a lot of |
@jgoux Currently is expected behavior. Providing The benefit of Also, I have another example to show why Let's imagine you have 3 documents
#import 'user-fields.gql'
query {
users {
...UserFields
}
}
fragment UserFields on User {
...
}
fragment UserFields on User { # `no-unused-fragments` rule will report an error for that unused fragment
...
} And for the completion, I'm okay to completely remove necessary for |
@jgoux @3nvi @mogelbrod the necessary of using |
@B2o5T: Tried the alpha release and it indeed looks like the plugin is now picking up fragments from other files without the Unfortunately I still get query MainQuery {
rootField { ...X }
} Where fragment X on Something {
id name
...on SomethingSpecific { ...Y }
}
fragment Y on SomethingSpecific {
more
} This happens whether I include |
Thanks for the feedback! I’ll look later to fix that problem 🙂 |
@mogelbrod my fixtures
query {
user {
...UserFields
}
}
fragment UserFields on User {
id
posts {
...on Post {
...PostFields
}
}
}
fragment PostFields on Post {
id
} UPDATE: found an issue, no need for repro 😄 |
@mogelbrod fixed in |
That seems to have solved the nested fragments issue, nice!
|
@mogelbrod can't reproduce 🤷♂️, what do you mean by |
I was able to consistently repro it in an un-shareable business environment, but would definitely like to try reproducing it in a csb or similar - do you have a preferred template I can use? And in case it would be helpful: by |
UPDATE: was able to reproduce, will fix it soon UPDATE 2: fixed in |
Hello all 👋,
Following the discussion here : #456 (comment)
Describe the bug
The rules
known-fragment-names
andno-unused-fragments
are erroring even if all my fragments are loaded by graphql-eslint.I edited the sources and logged the value of the
siblings
variable : https://github.com/dotansimha/graphql-eslint/blob/master/packages/plugin/src/sibling-operations.ts#L83-L88When I run eslint CLI, here is the output : https://gist.github.com/jgoux/73b79e57b96531f89ab6c99b089c2512
You can see the errors at the end : https://gist.github.com/jgoux/73b79e57b96531f89ab6c99b089c2512#file-log-sh-L796-L818
As an example, the
ProfileForm_user
fragment which is in error is properly detected and loaded here : https://gist.github.com/jgoux/73b79e57b96531f89ab6c99b089c2512#file-log-sh-L98-L105To Reproduce
Steps to reproduce the behavior:
Expected behavior
If all the fragments are detected by the plugin, I should have no errors in my case.
Environment:
@graphql-eslint/...
: 1.0.1Additional context
The text was updated successfully, but these errors were encountered: