Skip to content

Commit 4c7d7f6

Browse files
committed
Validation: unify error messages
1 parent 682fd4e commit 4c7d7f6

24 files changed

+195
-188
lines changed

src/type/__tests__/enumType-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe('Type System: Enum Values', () => {
155155
errors: [
156156
{
157157
message:
158-
'Expected type Color, found "GREEN". Did you mean the enum value GREEN?',
158+
'Expected value of type "Color", found "GREEN". Did you mean the enum value "GREEN"?',
159159
locations: [{ line: 1, column: 23 }],
160160
},
161161
],
@@ -169,7 +169,7 @@ describe('Type System: Enum Values', () => {
169169
errors: [
170170
{
171171
message:
172-
'Expected type Color, found GREENISH. Did you mean the enum value GREEN?',
172+
'Expected value of type "Color", found GREENISH. Did you mean the enum value "GREEN"?',
173173
locations: [{ line: 1, column: 23 }],
174174
},
175175
],
@@ -183,7 +183,7 @@ describe('Type System: Enum Values', () => {
183183
errors: [
184184
{
185185
message:
186-
'Expected type Color, found green. Did you mean the enum value GREEN?',
186+
'Expected value of type "Color", found green. Did you mean the enum value "GREEN"?',
187187
locations: [{ line: 1, column: 23 }],
188188
},
189189
],
@@ -211,7 +211,7 @@ describe('Type System: Enum Values', () => {
211211
expect(result).to.deep.equal({
212212
errors: [
213213
{
214-
message: 'Expected type Color, found 1.',
214+
message: 'Expected value of type "Color", found 1.',
215215
locations: [{ line: 1, column: 23 }],
216216
},
217217
],
@@ -224,7 +224,7 @@ describe('Type System: Enum Values', () => {
224224
expect(result).to.deep.equal({
225225
errors: [
226226
{
227-
message: 'Expected type Int, found GREEN.',
227+
message: 'Expected value of type "Int", found GREEN.',
228228
locations: [{ line: 1, column: 22 }],
229229
},
230230
],

src/utilities/__tests__/buildASTSchema-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ describe('Schema Builder', () => {
820820
foo: String @unknown
821821
}
822822
`;
823-
expect(() => buildSchema(sdl)).to.throw('Unknown directive "unknown".');
823+
expect(() => buildSchema(sdl)).to.throw('Unknown directive "@unknown".');
824824
});
825825

826826
it('Allows to disable SDL validation', () => {

src/utilities/__tests__/extendSchema-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ describe('extendSchema', () => {
10541054
extend schema @unknown
10551055
`;
10561056
expect(() => extendTestSchema(sdl)).to.throw(
1057-
'Unknown directive "unknown".',
1057+
'Unknown directive "@unknown".',
10581058
);
10591059
});
10601060

@@ -1072,7 +1072,7 @@ describe('extendSchema', () => {
10721072
`;
10731073

10741074
expect(() => extendTestSchema(sdl)).to.throw(
1075-
'Directive "include" already exists in the schema. It cannot be redefined.',
1075+
'Directive "@include" already exists in the schema. It cannot be redefined.',
10761076
);
10771077
});
10781078

src/validation/__tests__/ExecutableDefinitions-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ describe('Validate: Executable definitions', () => {
5757
}
5858
`).to.deep.equal([
5959
{
60-
message: 'The Cow definition is not executable.',
60+
message: 'The "Cow" definition is not executable.',
6161
locations: [{ line: 8, column: 7 }],
6262
},
6363
{
64-
message: 'The Dog definition is not executable.',
64+
message: 'The "Dog" definition is not executable.',
6565
locations: [{ line: 12, column: 7 }],
6666
},
6767
]);
@@ -84,7 +84,7 @@ describe('Validate: Executable definitions', () => {
8484
locations: [{ line: 2, column: 7 }],
8585
},
8686
{
87-
message: 'The Query definition is not executable.',
87+
message: 'The "Query" definition is not executable.',
8888
locations: [{ line: 6, column: 7 }],
8989
},
9090
{

src/validation/__tests__/KnownArgumentNames-test.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ describe('Validate: Known argument names', () => {
131131
}
132132
`).to.deep.equal([
133133
{
134-
message:
135-
'Unknown argument "unknown" on field "doesKnowCommand" of type "Dog".',
134+
message: 'Unknown argument "unknown" on field "Dog.doesKnowCommand".',
136135
locations: [{ line: 3, column: 25 }],
137136
},
138137
]);
@@ -146,7 +145,7 @@ describe('Validate: Known argument names', () => {
146145
`).to.deep.equal([
147146
{
148147
message:
149-
'Unknown argument "dogcommand" on field "doesKnowCommand" of type "Dog". Did you mean "dogCommand"?',
148+
'Unknown argument "dogcommand" on field "Dog.doesKnowCommand". Did you mean "dogCommand"?',
150149
locations: [{ line: 3, column: 25 }],
151150
},
152151
]);
@@ -159,13 +158,11 @@ describe('Validate: Known argument names', () => {
159158
}
160159
`).to.deep.equal([
161160
{
162-
message:
163-
'Unknown argument "whoknows" on field "doesKnowCommand" of type "Dog".',
161+
message: 'Unknown argument "whoknows" on field "Dog.doesKnowCommand".',
164162
locations: [{ line: 3, column: 25 }],
165163
},
166164
{
167-
message:
168-
'Unknown argument "unknown" on field "doesKnowCommand" of type "Dog".',
165+
message: 'Unknown argument "unknown" on field "Dog.doesKnowCommand".',
169166
locations: [{ line: 3, column: 55 }],
170167
},
171168
]);
@@ -187,13 +184,11 @@ describe('Validate: Known argument names', () => {
187184
}
188185
`).to.deep.equal([
189186
{
190-
message:
191-
'Unknown argument "unknown" on field "doesKnowCommand" of type "Dog".',
187+
message: 'Unknown argument "unknown" on field "Dog.doesKnowCommand".',
192188
locations: [{ line: 4, column: 27 }],
193189
},
194190
{
195-
message:
196-
'Unknown argument "unknown" on field "doesKnowCommand" of type "Dog".',
191+
message: 'Unknown argument "unknown" on field "Dog.doesKnowCommand".',
197192
locations: [{ line: 9, column: 31 }],
198193
},
199194
]);

src/validation/__tests__/KnownDirectives-test.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('Validate: Known directives', () => {
7474
}
7575
`).to.deep.equal([
7676
{
77-
message: 'Unknown directive "unknown".',
77+
message: 'Unknown directive "@unknown".',
7878
locations: [{ line: 3, column: 13 }],
7979
},
8080
]);
@@ -95,15 +95,15 @@ describe('Validate: Known directives', () => {
9595
}
9696
`).to.deep.equal([
9797
{
98-
message: 'Unknown directive "unknown".',
98+
message: 'Unknown directive "@unknown".',
9999
locations: [{ line: 3, column: 13 }],
100100
},
101101
{
102-
message: 'Unknown directive "unknown".',
102+
message: 'Unknown directive "@unknown".',
103103
locations: [{ line: 6, column: 15 }],
104104
},
105105
{
106-
message: 'Unknown directive "unknown".',
106+
message: 'Unknown directive "@unknown".',
107107
locations: [{ line: 8, column: 16 }],
108108
},
109109
]);
@@ -144,19 +144,19 @@ describe('Validate: Known directives', () => {
144144
}
145145
`).to.deep.equal([
146146
{
147-
message: 'Directive "include" may not be used on QUERY.',
147+
message: 'Directive "@include" may not be used on QUERY.',
148148
locations: [{ line: 2, column: 32 }],
149149
},
150150
{
151-
message: 'Directive "onQuery" may not be used on FIELD.',
151+
message: 'Directive "@onQuery" may not be used on FIELD.',
152152
locations: [{ line: 3, column: 14 }],
153153
},
154154
{
155-
message: 'Directive "onQuery" may not be used on FRAGMENT_SPREAD.',
155+
message: 'Directive "@onQuery" may not be used on FRAGMENT_SPREAD.',
156156
locations: [{ line: 4, column: 17 }],
157157
},
158158
{
159-
message: 'Directive "onQuery" may not be used on MUTATION.',
159+
message: 'Directive "@onQuery" may not be used on MUTATION.',
160160
locations: [{ line: 7, column: 20 }],
161161
},
162162
]);
@@ -169,7 +169,7 @@ describe('Validate: Known directives', () => {
169169
}
170170
`).to.deep.equal([
171171
{
172-
message: 'Directive "onField" may not be used on VARIABLE_DEFINITION.',
172+
message: 'Directive "@onField" may not be used on VARIABLE_DEFINITION.',
173173
locations: [{ line: 2, column: 31 }],
174174
},
175175
]);
@@ -248,7 +248,7 @@ describe('Validate: Known directives', () => {
248248
schema,
249249
).to.deep.equal([
250250
{
251-
message: 'Unknown directive "unknown".',
251+
message: 'Unknown directive "@unknown".',
252252
locations: [{ line: 2, column: 29 }],
253253
},
254254
]);
@@ -331,64 +331,64 @@ describe('Validate: Known directives', () => {
331331
schemaWithSDLDirectives,
332332
).to.deep.equal([
333333
{
334-
message: 'Directive "onInterface" may not be used on OBJECT.',
334+
message: 'Directive "@onInterface" may not be used on OBJECT.',
335335
locations: [{ line: 2, column: 45 }],
336336
},
337337
{
338338
message:
339-
'Directive "onInputFieldDefinition" may not be used on ARGUMENT_DEFINITION.',
339+
'Directive "@onInputFieldDefinition" may not be used on ARGUMENT_DEFINITION.',
340340
locations: [{ line: 3, column: 32 }],
341341
},
342342
{
343343
message:
344-
'Directive "onInputFieldDefinition" may not be used on FIELD_DEFINITION.',
344+
'Directive "@onInputFieldDefinition" may not be used on FIELD_DEFINITION.',
345345
locations: [{ line: 3, column: 65 }],
346346
},
347347
{
348-
message: 'Directive "onEnum" may not be used on SCALAR.',
348+
message: 'Directive "@onEnum" may not be used on SCALAR.',
349349
locations: [{ line: 6, column: 27 }],
350350
},
351351
{
352-
message: 'Directive "onObject" may not be used on INTERFACE.',
352+
message: 'Directive "@onObject" may not be used on INTERFACE.',
353353
locations: [{ line: 8, column: 33 }],
354354
},
355355
{
356356
message:
357-
'Directive "onInputFieldDefinition" may not be used on ARGUMENT_DEFINITION.',
357+
'Directive "@onInputFieldDefinition" may not be used on ARGUMENT_DEFINITION.',
358358
locations: [{ line: 9, column: 32 }],
359359
},
360360
{
361361
message:
362-
'Directive "onInputFieldDefinition" may not be used on FIELD_DEFINITION.',
362+
'Directive "@onInputFieldDefinition" may not be used on FIELD_DEFINITION.',
363363
locations: [{ line: 9, column: 65 }],
364364
},
365365
{
366-
message: 'Directive "onEnumValue" may not be used on UNION.',
366+
message: 'Directive "@onEnumValue" may not be used on UNION.',
367367
locations: [{ line: 12, column: 25 }],
368368
},
369369
{
370-
message: 'Directive "onScalar" may not be used on ENUM.',
370+
message: 'Directive "@onScalar" may not be used on ENUM.',
371371
locations: [{ line: 14, column: 23 }],
372372
},
373373
{
374-
message: 'Directive "onUnion" may not be used on ENUM_VALUE.',
374+
message: 'Directive "@onUnion" may not be used on ENUM_VALUE.',
375375
locations: [{ line: 15, column: 22 }],
376376
},
377377
{
378-
message: 'Directive "onEnum" may not be used on INPUT_OBJECT.',
378+
message: 'Directive "@onEnum" may not be used on INPUT_OBJECT.',
379379
locations: [{ line: 18, column: 25 }],
380380
},
381381
{
382382
message:
383-
'Directive "onArgumentDefinition" may not be used on INPUT_FIELD_DEFINITION.',
383+
'Directive "@onArgumentDefinition" may not be used on INPUT_FIELD_DEFINITION.',
384384
locations: [{ line: 19, column: 26 }],
385385
},
386386
{
387-
message: 'Directive "onObject" may not be used on SCHEMA.',
387+
message: 'Directive "@onObject" may not be used on SCHEMA.',
388388
locations: [{ line: 22, column: 18 }],
389389
},
390390
{
391-
message: 'Directive "onObject" may not be used on SCHEMA.',
391+
message: 'Directive "@onObject" may not be used on SCHEMA.',
392392
locations: [{ line: 26, column: 25 }],
393393
},
394394
]);

src/validation/__tests__/NoFragmentCycles-test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('Validate: No circular fragment spreads', () => {
102102
fragment fragB on Dog { ...fragA }
103103
`).to.deep.equal([
104104
{
105-
message: 'Cannot spread fragment "fragA" within itself via fragB.',
105+
message: 'Cannot spread fragment "fragA" within itself via "fragB".',
106106
locations: [{ line: 2, column: 31 }, { line: 3, column: 31 }],
107107
},
108108
]);
@@ -114,7 +114,7 @@ describe('Validate: No circular fragment spreads', () => {
114114
fragment fragA on Dog { ...fragB }
115115
`).to.deep.equal([
116116
{
117-
message: 'Cannot spread fragment "fragB" within itself via fragA.',
117+
message: 'Cannot spread fragment "fragB" within itself via "fragA".',
118118
locations: [{ line: 2, column: 31 }, { line: 3, column: 31 }],
119119
},
120120
]);
@@ -134,7 +134,7 @@ describe('Validate: No circular fragment spreads', () => {
134134
}
135135
`).to.deep.equal([
136136
{
137-
message: 'Cannot spread fragment "fragA" within itself via fragB.',
137+
message: 'Cannot spread fragment "fragA" within itself via "fragB".',
138138
locations: [{ line: 4, column: 11 }, { line: 9, column: 11 }],
139139
},
140140
]);
@@ -153,7 +153,7 @@ describe('Validate: No circular fragment spreads', () => {
153153
`).to.deep.equal([
154154
{
155155
message:
156-
'Cannot spread fragment "fragA" within itself via fragB, fragC, fragO, fragP.',
156+
'Cannot spread fragment "fragA" within itself via "fragB", "fragC", "fragO", "fragP".',
157157
locations: [
158158
{ line: 2, column: 31 },
159159
{ line: 3, column: 31 },
@@ -164,7 +164,7 @@ describe('Validate: No circular fragment spreads', () => {
164164
},
165165
{
166166
message:
167-
'Cannot spread fragment "fragO" within itself via fragP, fragX, fragY, fragZ.',
167+
'Cannot spread fragment "fragO" within itself via "fragP", "fragX", "fragY", "fragZ".',
168168
locations: [
169169
{ line: 8, column: 31 },
170170
{ line: 9, column: 41 },
@@ -183,11 +183,11 @@ describe('Validate: No circular fragment spreads', () => {
183183
fragment fragC on Dog { ...fragA }
184184
`).to.deep.equal([
185185
{
186-
message: 'Cannot spread fragment "fragA" within itself via fragB.',
186+
message: 'Cannot spread fragment "fragA" within itself via "fragB".',
187187
locations: [{ line: 2, column: 31 }, { line: 3, column: 31 }],
188188
},
189189
{
190-
message: 'Cannot spread fragment "fragA" within itself via fragC.',
190+
message: 'Cannot spread fragment "fragA" within itself via "fragC".',
191191
locations: [{ line: 2, column: 41 }, { line: 4, column: 31 }],
192192
},
193193
]);
@@ -200,11 +200,11 @@ describe('Validate: No circular fragment spreads', () => {
200200
fragment fragC on Dog { ...fragA, ...fragB }
201201
`).to.deep.equal([
202202
{
203-
message: 'Cannot spread fragment "fragA" within itself via fragC.',
203+
message: 'Cannot spread fragment "fragA" within itself via "fragC".',
204204
locations: [{ line: 2, column: 31 }, { line: 4, column: 31 }],
205205
},
206206
{
207-
message: 'Cannot spread fragment "fragC" within itself via fragB.',
207+
message: 'Cannot spread fragment "fragC" within itself via "fragB".',
208208
locations: [{ line: 4, column: 41 }, { line: 3, column: 31 }],
209209
},
210210
]);
@@ -222,15 +222,15 @@ describe('Validate: No circular fragment spreads', () => {
222222
},
223223
{
224224
message:
225-
'Cannot spread fragment "fragA" within itself via fragB, fragC.',
225+
'Cannot spread fragment "fragA" within itself via "fragB", "fragC".',
226226
locations: [
227227
{ line: 2, column: 31 },
228228
{ line: 3, column: 41 },
229229
{ line: 4, column: 31 },
230230
],
231231
},
232232
{
233-
message: 'Cannot spread fragment "fragB" within itself via fragC.',
233+
message: 'Cannot spread fragment "fragB" within itself via "fragC".',
234234
locations: [{ line: 3, column: 41 }, { line: 4, column: 41 }],
235235
},
236236
]);

0 commit comments

Comments
 (0)