No lint failure when fragment variable is not defined
See original GitHub issueDescribe the bug
- Given two
.graphql
files, one with aquery
operation and another with afragment
- 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:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in ``@graphql-eslint/eslint-plugin@2.3.0`
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.