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.

No lint failure when fragment variable is not defined

See original GitHub issue

Describe the bug

  • Given two .graphql files, one with a query operation and another with a fragment
  • And fragment uses a variable
  • And query does not define input variable

Then: there is no lint failure

(inverse of #651 )

To Reproduce Steps to reproduce the behavior:

git clone -b fragment-with-variable git@github.com:beaucollins/graphql-lint-fragment-variables.git
npm install
npm run lint

Expected behavior

The same error as if the fragment was embedded within the query:

./graphql-lint-fragment-variables/src/GetWidgets.graphql
  9:36  error  Variable "$usageInterval" is not defined by operation "AllWidgets"  @graphql-eslint/no-undefined-variables

Environment:

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
dotansimhacommented, Oct 20, 2021

Fixed in ``@graphql-eslint/eslint-plugin@2.3.0`

2reactions
beaucollinscommented, Sep 27, 2021

I don’t get errors from eslint, can you verify your branch?

Correct, not having an eslint error here is the problem. It’s a false negative.

It doesn’t produce a lint error but it should. The fragment requires a variable but the linter doesn’t understand that when the fragment is defined elsewhere.

As an example copy the contents of the fragment in place within the query operation and it will show an error.

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 >
Unable to instantiate Fragment - Stack Overflow
If I make my Fragment a static class, all my references to findViewById fail, which means a LOT of refactoring. How can I...
Read more >
Fragment | Android Developers
Though Fragment defines its own lifecycle, that lifecycle is dependent on its activity: if the activity is stopped, no fragments inside of it...
Read more >
Lint error: package fragment is not found for module ...
#15, I've set checkDependencies = false , but left our custom lint checks enabled. So far lint finished successfully without issue errors.
Read more >
usePaginationFragment - Relay
API reference for usePaginationFragment, a React hook used to paginate a connection.
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