Skip to content

Commit 1914d6a

Browse files
author
Dimitri POSTOLOV
authored
add test for known-fragment-names rule with import nested fragments + update graphql-tools/import package (#665)
* add failing test false positive case for `known-fragment-names` rule * chore: update deps
1 parent 70136fd commit 1914d6a

File tree

12 files changed

+379
-327
lines changed

12 files changed

+379
-327
lines changed

.changeset/short-dolphins-brush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': minor
3+
---
4+
5+
fix false positive case in `known-fragment-names` when import nested fragment

examples/basic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
},
1414
"devDependencies": {
1515
"@graphql-eslint/eslint-plugin": "2.4.1",
16-
"eslint": "8.1.0"
16+
"eslint": "8.2.0"
1717
}
1818
}

examples/code-file/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
},
1414
"devDependencies": {
1515
"@graphql-eslint/eslint-plugin": "2.4.1",
16-
"eslint": "8.1.0"
16+
"eslint": "8.2.0"
1717
}
1818
}

examples/graphql-config-code-file/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
},
1111
"dependencies": {
1212
"graphql": "16.0.1",
13-
"graphql-tag": "^2.12.5"
13+
"graphql-tag": "2.12.6"
1414
},
1515
"devDependencies": {
1616
"@graphql-eslint/eslint-plugin": "2.4.1",
17-
"eslint": "8.1.0"
17+
"eslint": "8.2.0"
1818
}
1919
}

examples/graphql-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
},
1414
"devDependencies": {
1515
"@graphql-eslint/eslint-plugin": "2.4.1",
16-
"eslint": "8.1.0"
16+
"eslint": "8.2.0"
1717
}
1818
}

examples/prettier/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"devDependencies": {
1515
"@graphql-eslint/eslint-plugin": "2.4.1",
16-
"eslint": "8.1.0",
16+
"eslint": "8.2.0",
1717
"eslint-config-prettier": "8.3.0",
1818
"eslint-plugin-prettier": "4.0.0",
1919
"prettier": "2.4.1"

packages/plugin/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
},
2828
"dependencies": {
2929
"@babel/code-frame": "7.16.0",
30-
"@graphql-tools/code-file-loader": "^7.0.2",
31-
"@graphql-tools/graphql-tag-pluck": "^7.0.2",
32-
"@graphql-tools/import": "^6.3.1",
33-
"@graphql-tools/utils": "^8.0.2",
34-
"graphql-config": "^4.0.1",
30+
"@graphql-tools/code-file-loader": "7.2.2",
31+
"@graphql-tools/graphql-tag-pluck": "7.1.3",
32+
"@graphql-tools/import": "6.6.1",
33+
"@graphql-tools/utils": "8.5.3",
34+
"graphql-config": "4.1.0",
3535
"graphql-depth-limit": "1.1.0",
36-
"lodash.lowercase": "^4.3.0"
36+
"lodash.lowercase": "4.3.0"
3737
},
3838
"devDependencies": {
3939
"@types/babel__code-frame": "7.0.3",

packages/plugin/tests/known-fragment-names.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { join } from 'path';
2-
import { GraphQLRuleTester } from '../src';
3-
import { GRAPHQL_JS_VALIDATIONS } from '../src/rules/graphql-js-validation';
2+
import { GraphQLRuleTester, rules } from '../src';
43

54
const ruleTester = new GraphQLRuleTester();
65

7-
ruleTester.runGraphQLTests('known-fragment-names', GRAPHQL_JS_VALIDATIONS['known-fragment-names'], {
6+
ruleTester.runGraphQLTests('known-fragment-names', rules['known-fragment-names'], {
87
valid: [
98
{
109
filename: join(__dirname, 'mocks/user.graphql'),
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
fragment UserFields on User {
2+
...AnotherUserFields
3+
posts {
4+
...PostFields
5+
}
6+
}
7+
8+
fragment AnotherUserFields on User {
9+
firstName
10+
}
11+
12+
fragment PostFields on Post {
13+
id
14+
...AnotherPostFields
15+
}
16+
17+
fragment AnotherPostFields on Post {
18+
title
19+
...YetAnotherPostFields
20+
}
21+
22+
fragment YetAnotherPostFields on Post {
23+
content
24+
}

packages/plugin/tests/mocks/user.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "./user-fields.graphql"
1+
#import './user-fields-with-nested-fragment.gql'
22

33
query User {
44
user {

0 commit comments

Comments
 (0)