Skip to content

Commit

Permalink
Validation: unify error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Sep 10, 2019
1 parent 682fd4e commit dd2afd7
Show file tree
Hide file tree
Showing 24 changed files with 193 additions and 183 deletions.
10 changes: 5 additions & 5 deletions src/type/__tests__/enumType-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe('Type System: Enum Values', () => {
errors: [
{
message:
'Expected type Color, found "GREEN". Did you mean the enum value GREEN?',
'Expected value of type "Color", found "GREEN". Did you mean the enum value "GREEN"?',
locations: [{ line: 1, column: 23 }],
},
],
Expand All @@ -169,7 +169,7 @@ describe('Type System: Enum Values', () => {
errors: [
{
message:
'Expected type Color, found GREENISH. Did you mean the enum value GREEN?',
'Expected value of type "Color", found GREENISH. Did you mean the enum value "GREEN"?',
locations: [{ line: 1, column: 23 }],
},
],
Expand All @@ -183,7 +183,7 @@ describe('Type System: Enum Values', () => {
errors: [
{
message:
'Expected type Color, found green. Did you mean the enum value GREEN?',
'Expected value of type "Color", found green. Did you mean the enum value "GREEN"?',
locations: [{ line: 1, column: 23 }],
},
],
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('Type System: Enum Values', () => {
expect(result).to.deep.equal({
errors: [
{
message: 'Expected type Color, found 1.',
message: 'Expected value of type "Color", found 1.',
locations: [{ line: 1, column: 23 }],
},
],
Expand All @@ -224,7 +224,7 @@ describe('Type System: Enum Values', () => {
expect(result).to.deep.equal({
errors: [
{
message: 'Expected type Int, found GREEN.',
message: 'Expected value of type "Int", found GREEN.',
locations: [{ line: 1, column: 22 }],
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/__tests__/buildASTSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ describe('Schema Builder', () => {
foo: String @unknown
}
`;
expect(() => buildSchema(sdl)).to.throw('Unknown directive "unknown".');
expect(() => buildSchema(sdl)).to.throw('Unknown directive "@unknown".');
});

it('Allows to disable SDL validation', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/__tests__/extendSchema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ describe('extendSchema', () => {
extend schema @unknown
`;
expect(() => extendTestSchema(sdl)).to.throw(
'Unknown directive "unknown".',
'Unknown directive "@unknown".',
);
});

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

expect(() => extendTestSchema(sdl)).to.throw(
'Directive "include" already exists in the schema. It cannot be redefined.',
'Directive "@include" already exists in the schema. It cannot be redefined.',
);
});

Expand Down
6 changes: 3 additions & 3 deletions src/validation/__tests__/ExecutableDefinitions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ describe('Validate: Executable definitions', () => {
}
`).to.deep.equal([
{
message: 'The Cow definition is not executable.',
message: 'The "Cow" definition is not executable.',
locations: [{ line: 8, column: 7 }],
},
{
message: 'The Dog definition is not executable.',
message: 'The "Dog" definition is not executable.',
locations: [{ line: 12, column: 7 }],
},
]);
Expand All @@ -84,7 +84,7 @@ describe('Validate: Executable definitions', () => {
locations: [{ line: 2, column: 7 }],
},
{
message: 'The Query definition is not executable.',
message: 'The "Query" definition is not executable.',
locations: [{ line: 6, column: 7 }],
},
{
Expand Down
12 changes: 6 additions & 6 deletions src/validation/__tests__/KnownArgumentNames-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('Validate: Known argument names', () => {
`).to.deep.equal([
{
message:
'Unknown argument "unknown" on field "doesKnowCommand" of type "Dog".',
'Unknown argument "unknown" on field "Dog.doesKnowCommand".',
locations: [{ line: 3, column: 25 }],
},
]);
Expand All @@ -146,7 +146,7 @@ describe('Validate: Known argument names', () => {
`).to.deep.equal([
{
message:
'Unknown argument "dogcommand" on field "doesKnowCommand" of type "Dog". Did you mean "dogCommand"?',
'Unknown argument "dogcommand" on field "Dog.doesKnowCommand". Did you mean "dogCommand"?',
locations: [{ line: 3, column: 25 }],
},
]);
Expand All @@ -160,12 +160,12 @@ describe('Validate: Known argument names', () => {
`).to.deep.equal([
{
message:
'Unknown argument "whoknows" on field "doesKnowCommand" of type "Dog".',
'Unknown argument "whoknows" on field "Dog.doesKnowCommand".',
locations: [{ line: 3, column: 25 }],
},
{
message:
'Unknown argument "unknown" on field "doesKnowCommand" of type "Dog".',
'Unknown argument "unknown" on field "Dog.doesKnowCommand".',
locations: [{ line: 3, column: 55 }],
},
]);
Expand All @@ -188,12 +188,12 @@ describe('Validate: Known argument names', () => {
`).to.deep.equal([
{
message:
'Unknown argument "unknown" on field "doesKnowCommand" of type "Dog".',
'Unknown argument "unknown" on field "Dog.doesKnowCommand".',
locations: [{ line: 4, column: 27 }],
},
{
message:
'Unknown argument "unknown" on field "doesKnowCommand" of type "Dog".',
'Unknown argument "unknown" on field "Dog.doesKnowCommand".',
locations: [{ line: 9, column: 31 }],
},
]);
Expand Down
48 changes: 24 additions & 24 deletions src/validation/__tests__/KnownDirectives-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('Validate: Known directives', () => {
}
`).to.deep.equal([
{
message: 'Unknown directive "unknown".',
message: 'Unknown directive "@unknown".',
locations: [{ line: 3, column: 13 }],
},
]);
Expand All @@ -95,15 +95,15 @@ describe('Validate: Known directives', () => {
}
`).to.deep.equal([
{
message: 'Unknown directive "unknown".',
message: 'Unknown directive "@unknown".',
locations: [{ line: 3, column: 13 }],
},
{
message: 'Unknown directive "unknown".',
message: 'Unknown directive "@unknown".',
locations: [{ line: 6, column: 15 }],
},
{
message: 'Unknown directive "unknown".',
message: 'Unknown directive "@unknown".',
locations: [{ line: 8, column: 16 }],
},
]);
Expand Down Expand Up @@ -144,19 +144,19 @@ describe('Validate: Known directives', () => {
}
`).to.deep.equal([
{
message: 'Directive "include" may not be used on QUERY.',
message: 'Directive "@include" may not be used on QUERY.',
locations: [{ line: 2, column: 32 }],
},
{
message: 'Directive "onQuery" may not be used on FIELD.',
message: 'Directive "@onQuery" may not be used on FIELD.',
locations: [{ line: 3, column: 14 }],
},
{
message: 'Directive "onQuery" may not be used on FRAGMENT_SPREAD.',
message: 'Directive "@onQuery" may not be used on FRAGMENT_SPREAD.',
locations: [{ line: 4, column: 17 }],
},
{
message: 'Directive "onQuery" may not be used on MUTATION.',
message: 'Directive "@onQuery" may not be used on MUTATION.',
locations: [{ line: 7, column: 20 }],
},
]);
Expand All @@ -169,7 +169,7 @@ describe('Validate: Known directives', () => {
}
`).to.deep.equal([
{
message: 'Directive "onField" may not be used on VARIABLE_DEFINITION.',
message: 'Directive "@onField" may not be used on VARIABLE_DEFINITION.',
locations: [{ line: 2, column: 31 }],
},
]);
Expand Down Expand Up @@ -248,7 +248,7 @@ describe('Validate: Known directives', () => {
schema,
).to.deep.equal([
{
message: 'Unknown directive "unknown".',
message: 'Unknown directive "@unknown".',
locations: [{ line: 2, column: 29 }],
},
]);
Expand Down Expand Up @@ -331,64 +331,64 @@ describe('Validate: Known directives', () => {
schemaWithSDLDirectives,
).to.deep.equal([
{
message: 'Directive "onInterface" may not be used on OBJECT.',
message: 'Directive "@onInterface" may not be used on OBJECT.',
locations: [{ line: 2, column: 45 }],
},
{
message:
'Directive "onInputFieldDefinition" may not be used on ARGUMENT_DEFINITION.',
'Directive "@onInputFieldDefinition" may not be used on ARGUMENT_DEFINITION.',
locations: [{ line: 3, column: 32 }],
},
{
message:
'Directive "onInputFieldDefinition" may not be used on FIELD_DEFINITION.',
'Directive "@onInputFieldDefinition" may not be used on FIELD_DEFINITION.',
locations: [{ line: 3, column: 65 }],
},
{
message: 'Directive "onEnum" may not be used on SCALAR.',
message: 'Directive "@onEnum" may not be used on SCALAR.',
locations: [{ line: 6, column: 27 }],
},
{
message: 'Directive "onObject" may not be used on INTERFACE.',
message: 'Directive "@onObject" may not be used on INTERFACE.',
locations: [{ line: 8, column: 33 }],
},
{
message:
'Directive "onInputFieldDefinition" may not be used on ARGUMENT_DEFINITION.',
'Directive "@onInputFieldDefinition" may not be used on ARGUMENT_DEFINITION.',
locations: [{ line: 9, column: 32 }],
},
{
message:
'Directive "onInputFieldDefinition" may not be used on FIELD_DEFINITION.',
'Directive "@onInputFieldDefinition" may not be used on FIELD_DEFINITION.',
locations: [{ line: 9, column: 65 }],
},
{
message: 'Directive "onEnumValue" may not be used on UNION.',
message: 'Directive "@onEnumValue" may not be used on UNION.',
locations: [{ line: 12, column: 25 }],
},
{
message: 'Directive "onScalar" may not be used on ENUM.',
message: 'Directive "@onScalar" may not be used on ENUM.',
locations: [{ line: 14, column: 23 }],
},
{
message: 'Directive "onUnion" may not be used on ENUM_VALUE.',
message: 'Directive "@onUnion" may not be used on ENUM_VALUE.',
locations: [{ line: 15, column: 22 }],
},
{
message: 'Directive "onEnum" may not be used on INPUT_OBJECT.',
message: 'Directive "@onEnum" may not be used on INPUT_OBJECT.',
locations: [{ line: 18, column: 25 }],
},
{
message:
'Directive "onArgumentDefinition" may not be used on INPUT_FIELD_DEFINITION.',
'Directive "@onArgumentDefinition" may not be used on INPUT_FIELD_DEFINITION.',
locations: [{ line: 19, column: 26 }],
},
{
message: 'Directive "onObject" may not be used on SCHEMA.',
message: 'Directive "@onObject" may not be used on SCHEMA.',
locations: [{ line: 22, column: 18 }],
},
{
message: 'Directive "onObject" may not be used on SCHEMA.',
message: 'Directive "@onObject" may not be used on SCHEMA.',
locations: [{ line: 26, column: 25 }],
},
]);
Expand Down
22 changes: 11 additions & 11 deletions src/validation/__tests__/NoFragmentCycles-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('Validate: No circular fragment spreads', () => {
fragment fragB on Dog { ...fragA }
`).to.deep.equal([
{
message: 'Cannot spread fragment "fragA" within itself via fragB.',
message: 'Cannot spread fragment "fragA" within itself via "fragB".',
locations: [{ line: 2, column: 31 }, { line: 3, column: 31 }],
},
]);
Expand All @@ -114,7 +114,7 @@ describe('Validate: No circular fragment spreads', () => {
fragment fragA on Dog { ...fragB }
`).to.deep.equal([
{
message: 'Cannot spread fragment "fragB" within itself via fragA.',
message: 'Cannot spread fragment "fragB" within itself via "fragA".',
locations: [{ line: 2, column: 31 }, { line: 3, column: 31 }],
},
]);
Expand All @@ -134,7 +134,7 @@ describe('Validate: No circular fragment spreads', () => {
}
`).to.deep.equal([
{
message: 'Cannot spread fragment "fragA" within itself via fragB.',
message: 'Cannot spread fragment "fragA" within itself via "fragB".',
locations: [{ line: 4, column: 11 }, { line: 9, column: 11 }],
},
]);
Expand All @@ -153,7 +153,7 @@ describe('Validate: No circular fragment spreads', () => {
`).to.deep.equal([
{
message:
'Cannot spread fragment "fragA" within itself via fragB, fragC, fragO, fragP.',
'Cannot spread fragment "fragA" within itself via "fragB", "fragC", "fragO", "fragP".',
locations: [
{ line: 2, column: 31 },
{ line: 3, column: 31 },
Expand All @@ -164,7 +164,7 @@ describe('Validate: No circular fragment spreads', () => {
},
{
message:
'Cannot spread fragment "fragO" within itself via fragP, fragX, fragY, fragZ.',
'Cannot spread fragment "fragO" within itself via "fragP", "fragX", "fragY", "fragZ".',
locations: [
{ line: 8, column: 31 },
{ line: 9, column: 41 },
Expand All @@ -183,11 +183,11 @@ describe('Validate: No circular fragment spreads', () => {
fragment fragC on Dog { ...fragA }
`).to.deep.equal([
{
message: 'Cannot spread fragment "fragA" within itself via fragB.',
message: 'Cannot spread fragment "fragA" within itself via "fragB".',
locations: [{ line: 2, column: 31 }, { line: 3, column: 31 }],
},
{
message: 'Cannot spread fragment "fragA" within itself via fragC.',
message: 'Cannot spread fragment "fragA" within itself via "fragC".',
locations: [{ line: 2, column: 41 }, { line: 4, column: 31 }],
},
]);
Expand All @@ -200,11 +200,11 @@ describe('Validate: No circular fragment spreads', () => {
fragment fragC on Dog { ...fragA, ...fragB }
`).to.deep.equal([
{
message: 'Cannot spread fragment "fragA" within itself via fragC.',
message: 'Cannot spread fragment "fragA" within itself via "fragC".',
locations: [{ line: 2, column: 31 }, { line: 4, column: 31 }],
},
{
message: 'Cannot spread fragment "fragC" within itself via fragB.',
message: 'Cannot spread fragment "fragC" within itself via "fragB".',
locations: [{ line: 4, column: 41 }, { line: 3, column: 31 }],
},
]);
Expand All @@ -222,15 +222,15 @@ describe('Validate: No circular fragment spreads', () => {
},
{
message:
'Cannot spread fragment "fragA" within itself via fragB, fragC.',
'Cannot spread fragment "fragA" within itself via "fragB", "fragC".',
locations: [
{ line: 2, column: 31 },
{ line: 3, column: 41 },
{ line: 4, column: 31 },
],
},
{
message: 'Cannot spread fragment "fragB" within itself via fragC.',
message: 'Cannot spread fragment "fragB" within itself via "fragC".',
locations: [{ line: 3, column: 41 }, { line: 4, column: 41 }],
},
]);
Expand Down
Loading

0 comments on commit dd2afd7

Please sign in to comment.