-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix error report location for
graphql-js
rules (#837)
- Loading branch information
1 parent
2c73cb7
commit 503dd9f
Showing
8 changed files
with
105 additions
and
25 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': patch | ||
--- | ||
|
||
fix error report location for `graphql-js` rules |
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
19 changes: 19 additions & 0 deletions
19
packages/plugin/tests/__snapshots__/fields-on-correct-type.spec.ts.snap
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,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[` 1`] = ` | ||
> 1 | fragment UserFields on User { id bad age } | ||
| ^^^ Cannot query field "bad" on type "User". Did you mean "id"? | ||
`; | ||
|
||
exports[` 2`] = ` | ||
1 | | ||
2 | { | ||
3 | user { | ||
4 | id | ||
> 5 | veryBad | ||
| ^^^^^^^ Cannot query field "veryBad" on type "User". | ||
6 | age | ||
7 | } | ||
8 | } | ||
9 | | ||
`; |
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
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,41 @@ | ||
import { GraphQLRuleTester, rules, ParserOptions } from '../src'; | ||
|
||
const parserOptions: ParserOptions = { | ||
schema: /* GraphQL */ ` | ||
type User { | ||
id: ID | ||
age: Int | ||
} | ||
type Query { | ||
user: User | ||
} | ||
`, | ||
}; | ||
const ruleTester = new GraphQLRuleTester(); | ||
|
||
ruleTester.runGraphQLTests('fields-on-correct-type', rules['fields-on-correct-type'], { | ||
valid: [], | ||
invalid: [ | ||
{ | ||
name: 'should highlight selection on single line', | ||
code: 'fragment UserFields on User { id bad age }', | ||
parserOptions, | ||
errors: [{ message: 'Cannot query field "bad" on type "User". Did you mean "id"?' }], | ||
}, | ||
{ | ||
name: 'should highlight selection on multi line', | ||
code: /* GraphQL */ ` | ||
{ | ||
user { | ||
id | ||
veryBad | ||
age | ||
} | ||
} | ||
`, | ||
parserOptions, | ||
errors: [{ message: 'Cannot query field "veryBad" on type "User".' }], | ||
}, | ||
], | ||
}); |