@@ -30,37 +30,49 @@ ruleTester.runGraphQLTests('validate-against-schema', rule, {
30
30
options : [ { overrideRules : [ 'NoUnusedVariablesRule' ] } ] ,
31
31
code : `query named ($id: ID!) { user(id: $id) { id @client } }` ,
32
32
} ,
33
+ {
34
+ ...WITH_SCHEMA ,
35
+ code : `fragment UserFields on User { id }` ,
36
+ } ,
37
+ {
38
+ ...WITH_SCHEMA ,
39
+ code : `fragment UserFields on User { id }` ,
40
+ } ,
41
+ {
42
+ ...WITH_SCHEMA ,
43
+ code : `query { user(id: 1) { ...UserFields } }` ,
44
+ } ,
33
45
] ,
34
46
invalid : [
35
47
{
36
48
...WITH_SCHEMA ,
37
49
code : `query { user(id: 1) { notExists } }` ,
38
- errors : [ 'Cannot query field "notExists" on type "User".' ] ,
50
+ errors : [ '[FieldsOnCorrectTypeRule] Cannot query field "notExists" on type "User".' ] ,
39
51
} ,
40
52
{
41
53
...WITH_SCHEMA ,
42
54
options : [ { overrideRules : [ 'NoUnusedVariablesRule' ] } ] ,
43
55
code : `query named ($id: ID!) { user(id: 2) { id @client } }` ,
44
- errors : [ 'Variable "$id" is never used in operation "named".' ] ,
56
+ errors : [ '[NoUnusedVariablesRule] Variable "$id" is never used in operation "named".' ] ,
45
57
} ,
46
58
{
47
59
...WITH_SCHEMA ,
48
- errors : [ 'Unknown directive "@client".' ] ,
60
+ errors : [ '[KnownDirectivesRule] Unknown directive "@client".' ] ,
49
61
code : `query named ($id: ID!) { user(id: $id) { id @client } }` ,
50
62
} ,
51
63
{
52
64
...WITH_SCHEMA ,
53
- errors : [ 'Unknown directive "@client".' ] ,
65
+ errors : [ '[KnownDirectivesRule] Unknown directive "@client".' ] ,
54
66
options : [ { overrideRules : [ 'KnownDirectivesRule' ] } ] ,
55
67
code : `query named ($id: ID!) { user(id: $id) { id @client } }` ,
56
68
} ,
57
69
{
58
70
...WITH_SCHEMA ,
59
71
code : `query test($id: ID!) { user(invalid: $id) { test } }` ,
60
72
errors : [
61
- 'Unknown argument "invalid" on field "Query.user" .' ,
62
- 'Cannot query field "test " on type "User ".' ,
63
- 'Field "user" argument "id" of type "ID!" is required, but it was not provided .' ,
73
+ '[ProvidedRequiredArgumentsRule] Field "user" argument "id" of type "ID!" is required, but it was not provided .' ,
74
+ '[KnownArgumentNamesRule] Unknown argument "invalid " on field "Query.user ".' ,
75
+ '[FieldsOnCorrectTypeRule] Cannot query field "test" on type "User" .' ,
64
76
] ,
65
77
} ,
66
78
] ,
0 commit comments