question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fragments are not properly detected for the `known-fragment-names` rule

See original GitHub issue

Hello all 👋,

Following the discussion here : https://github.com/dotansimha/graphql-eslint/discussions/456#discussioncomment-781188

Describe the bug

The rules known-fragment-names and no-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-L88

When 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-L105

To 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:

  • OS: MacOS Big Sur
  • @graphql-eslint/...: 1.0.1
  • NodeJS: v14.15.5

Additional context

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
mogelbrodcommented, Oct 8, 2021

I just discovered this great project and had the same experience as @jgoux. From reading the docs I assumed the operations field removed the need to add import statements to the graphql files. Other than that everything appears to work well!

3reactions
mogelbrodcommented, Dec 9, 2021

@mogelbrod fixed in 3.2.0-alpha-6aa2721.0, the related test was added also

That seems to have solved the nested fragments issue, nice! It appears that specifying undefined fragments causes stack overflows in this version though:

Oops! Something went wrong! :(
ESLint: 7.25.0
RangeError: Maximum call stack size exceeded
Occurred while linting .../src/routes/Library.graphql:0
    at typeFromAST (.../node_modules/graphql/utilities/typeFromAST.js:16:21)
    at typeFromAST (.../node_modules/graphql/utilities/typeFromAST.js:25:17)
    at TypeInfo.enter (.../node_modules/graphql/utilities/TypeInfo.js:186:56)
    at Object.enter (.../node_modules/graphql/utilities/TypeInfo.js:383:16)
    at Object.visit (.../node_modules/graphql/language/visitor.js:200:21)
    at getFragmentDefsAndFragmentSpreads (.../node_modules/@graphql-eslint/eslint-plugin/index.js:374:13)
    at getMissingFragments (.../node_modules/@graphql-eslint/eslint-plugin/index.js:378:47)
    at handleMissingFragments (.../node_modules/@graphql-eslint/eslint-plugin/index.js:382:30)
    at handleMissingFragments (.../node_modules/@graphql-eslint/eslint-plugin/index.js:396:20)
    at handleMissingFragments (.../node_modules/@graphql-eslint/eslint-plugin/index.js:396:20)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected @graphql-eslint/known-fragment-names when ...
It appears that a certain depth of fragment use in an operations document is not able to be found. I tried moving the...
Read more >
Text Fragments - GitHub Pages
This scroll can be indicative of whether the text fragment was successfully found on the page. Two users share the same network on...
Read more >
graphql-eslint - Bountysource
ESLint parser, plugin and set rules for GraphQL (for schema and operations). Easily customizable with custom rules. Integrates with IDEs and modern GraphQL ......
Read more >
Combining variant detection and fragment length analysis ...
There is an unmet clinical need to identify stage II–IIIA NSCLC patients who have been successfully cured by surgery alone and will not...
Read more >
Fragments – GraphQL Shield
A common example of this is using an id field to perform authorization checks; an initial query might not request the id field,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found