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.

Unexpected @graphql-eslint/known-fragment-names when using fragments within fragments

See original GitHub issue

Describe the bug

Not precisely sure what the exact requirements are but this is close to what we have in our codebase. It appears that a certain depth of fragment use in an operations document is not able to be found. I tried moving the fragment definitions in different orders with the same result.

Moving the fragments into the same file as the operation that uses them will cause the error to go away.

Also the line numbers that are reported are the wrong file and not the correct location if they were in the other file.

https://github.com/beaucollins/graphql-lint-fragment-variables/runs/3715892638

To Reproduce Steps to reproduce the behavior:

git clone -b fragment-not-found git@github.com:beaucollins/graphql-lint-fragment-variables.git
npm install
npm run lint
graphql-lint-fragment-variables/src/admin/allOwners.graphql
  11:9  error  Unknown fragment "TimelineEntry"  @graphql-eslint/known-fragment-names
  14:9  error  Unknown fragment "TimelineEntry"  @graphql-eslint/known-fragment-names

Expected behavior

The fragment should be found and validated correctly. Copying the contents of sharedFields.graphql into allOwners.graphql shows the expected result.

Environment:

  • OS: macOS 11.5.2
  • @graphql-eslint/eslint-plugin@2.2.0
  • NodeJS: v16.9.1

Additional context

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
FreekVRcommented, Jan 5, 2022

I am actually running into the same issues in my project, using a default and not a named import, with eslint-plugin@latest 😦

2reactions
B2o5Tcommented, Nov 16, 2021

I tested it with default import, but forget to test with named import, I think we need adjust a fix for named import too

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected @graphql-eslint/known-fragment-names when ...
I tried moving the fragment definitions in different orders with the same result. Moving the fragments into the same file as the operation...
Read more >
Fragments - Apollo GraphQL Docs
A GraphQL fragment is a piece of logic that can be shared between multiple queries and mutations. Here's the declaration of a NameParts...
Read more >
graphql-eslint - Bountysource
Our graphql systems support an #import directive in graphql files to allow sharing fragments between operations in different files. e.g. #import '.
Read more >
use fragments with vanilla apollo client - Stack Overflow
It seems like that createFragment hab been removed from the API. If you want to create a fragment you can use gql from...
Read more >
GraphQL Fragments are amazing! - Medium
During debugging this unexpected situation, it quickly became clear that the issue was because of how we were using GraphQL fragments when ...
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