Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix false negative case for
no-undefined-variables
rule (#659)
Co-authored-by: Dotan Simha <dotansimha@gmail.com>
- Loading branch information
1 parent
afc25b9
commit 44a6c73
Showing
6 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@graphql-eslint/eslint-plugin': minor | ||
--- | ||
|
||
fix false negative case for `no-undefined-variables` rule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#import UserFields from './user-fields-with-variables.gql' | ||
|
||
query User { | ||
user { | ||
id | ||
...UserFields | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fragment UserFields on User { | ||
firstName | ||
posts(limit: $limit, offset: $offset) { | ||
id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { join } from 'path'; | ||
import { GraphQLRuleTester, rules } from '../src'; | ||
|
||
const ruleTester = new GraphQLRuleTester(); | ||
|
||
ruleTester.runGraphQLTests('no-undefined-variables', rules['no-undefined-variables'], { | ||
valid: [], | ||
invalid: [ | ||
{ | ||
filename: join(__dirname, 'mocks/no-undefined-variables.gql'), | ||
code: ruleTester.fromMockFile('no-undefined-variables.gql'), | ||
parserOptions: { | ||
schema: join(__dirname, 'mocks/user-schema.graphql'), | ||
}, | ||
errors: [ | ||
{ message: 'Variable "$limit" is not defined by operation "User".' }, | ||
{ message: 'Variable "$offset" is not defined by operation "User".' }, | ||
], | ||
}, | ||
], | ||
}); |