From dd2afd7b451e1879051491e005971b4828eac30c Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Tue, 10 Sep 2019 22:19:30 +0300 Subject: [PATCH] Validation: unify error messages --- src/type/__tests__/enumType-test.js | 10 +- .../__tests__/buildASTSchema-test.js | 2 +- src/utilities/__tests__/extendSchema-test.js | 4 +- .../__tests__/ExecutableDefinitions-test.js | 6 +- .../__tests__/KnownArgumentNames-test.js | 12 +-- .../__tests__/KnownDirectives-test.js | 48 +++++----- .../__tests__/NoFragmentCycles-test.js | 22 ++--- .../OverlappingFieldsCanBeMerged-test.js | 44 ++++----- .../__tests__/PossibleTypeExtensions-test.js | 24 ++--- .../__tests__/UniqueDirectiveNames-test.js | 6 +- .../UniqueDirectivesPerLocation-test.js | 38 ++++---- .../__tests__/UniqueVariableNames-test.js | 8 +- .../__tests__/ValuesOfCorrectType-test.js | 96 +++++++++---------- src/validation/__tests__/validation-test.js | 2 +- src/validation/rules/ExecutableDefinitions.js | 2 +- src/validation/rules/KnownArgumentNames.js | 2 +- src/validation/rules/KnownDirectives.js | 4 +- src/validation/rules/NoFragmentCycles.js | 7 +- .../rules/OverlappingFieldsCanBeMerged.js | 6 +- .../rules/PossibleTypeExtensions.js | 2 +- src/validation/rules/UniqueDirectiveNames.js | 4 +- .../rules/UniqueDirectivesPerLocation.js | 2 +- src/validation/rules/UniqueVariableNames.js | 2 +- src/validation/rules/ValuesOfCorrectType.js | 23 +++-- 24 files changed, 193 insertions(+), 183 deletions(-) diff --git a/src/type/__tests__/enumType-test.js b/src/type/__tests__/enumType-test.js index b650339f5b..0d2dae138f 100644 --- a/src/type/__tests__/enumType-test.js +++ b/src/type/__tests__/enumType-test.js @@ -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 }], }, ], @@ -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 }], }, ], @@ -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 }], }, ], @@ -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 }], }, ], @@ -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 }], }, ], diff --git a/src/utilities/__tests__/buildASTSchema-test.js b/src/utilities/__tests__/buildASTSchema-test.js index 8fc68ef3d6..83edc697a0 100644 --- a/src/utilities/__tests__/buildASTSchema-test.js +++ b/src/utilities/__tests__/buildASTSchema-test.js @@ -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', () => { diff --git a/src/utilities/__tests__/extendSchema-test.js b/src/utilities/__tests__/extendSchema-test.js index e76be144cb..690051307b 100644 --- a/src/utilities/__tests__/extendSchema-test.js +++ b/src/utilities/__tests__/extendSchema-test.js @@ -1054,7 +1054,7 @@ describe('extendSchema', () => { extend schema @unknown `; expect(() => extendTestSchema(sdl)).to.throw( - 'Unknown directive "unknown".', + 'Unknown directive "@unknown".', ); }); @@ -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.', ); }); diff --git a/src/validation/__tests__/ExecutableDefinitions-test.js b/src/validation/__tests__/ExecutableDefinitions-test.js index 2bf551bfc7..b2f97985c6 100644 --- a/src/validation/__tests__/ExecutableDefinitions-test.js +++ b/src/validation/__tests__/ExecutableDefinitions-test.js @@ -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 }], }, ]); @@ -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 }], }, { diff --git a/src/validation/__tests__/KnownArgumentNames-test.js b/src/validation/__tests__/KnownArgumentNames-test.js index 4ea92f27c3..8aa72bf45a 100644 --- a/src/validation/__tests__/KnownArgumentNames-test.js +++ b/src/validation/__tests__/KnownArgumentNames-test.js @@ -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 }], }, ]); @@ -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 }], }, ]); @@ -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 }], }, ]); @@ -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 }], }, ]); diff --git a/src/validation/__tests__/KnownDirectives-test.js b/src/validation/__tests__/KnownDirectives-test.js index 899715352a..d875cbc4a1 100644 --- a/src/validation/__tests__/KnownDirectives-test.js +++ b/src/validation/__tests__/KnownDirectives-test.js @@ -74,7 +74,7 @@ describe('Validate: Known directives', () => { } `).to.deep.equal([ { - message: 'Unknown directive "unknown".', + message: 'Unknown directive "@unknown".', locations: [{ line: 3, column: 13 }], }, ]); @@ -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 }], }, ]); @@ -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 }], }, ]); @@ -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 }], }, ]); @@ -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 }], }, ]); @@ -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 }], }, ]); diff --git a/src/validation/__tests__/NoFragmentCycles-test.js b/src/validation/__tests__/NoFragmentCycles-test.js index 55ad865944..8f789709ff 100644 --- a/src/validation/__tests__/NoFragmentCycles-test.js +++ b/src/validation/__tests__/NoFragmentCycles-test.js @@ -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 }], }, ]); @@ -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 }], }, ]); @@ -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 }], }, ]); @@ -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 }, @@ -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 }, @@ -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 }], }, ]); @@ -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 }], }, ]); @@ -222,7 +222,7 @@ 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 }, @@ -230,7 +230,7 @@ describe('Validate: No circular fragment spreads', () => { ], }, { - 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 }], }, ]); diff --git a/src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js b/src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js index cd259ef001..23ead587b8 100644 --- a/src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js +++ b/src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js @@ -107,7 +107,7 @@ describe('Validate: Overlapping fields can be merged', () => { `).to.deep.equal([ { message: - 'Fields "fido" conflict because name and nickname are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "fido" conflict because "name" and "nickname" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [{ line: 3, column: 9 }, { line: 4, column: 9 }], }, ]); @@ -137,7 +137,7 @@ describe('Validate: Overlapping fields can be merged', () => { `).to.deep.equal([ { message: - 'Fields "name" conflict because nickname and name are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "name" conflict because "nickname" and "name" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [{ line: 3, column: 9 }, { line: 4, column: 9 }], }, ]); @@ -218,7 +218,7 @@ describe('Validate: Overlapping fields can be merged', () => { `).to.deep.equal([ { message: - 'Fields "x" conflict because a and b are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "x" conflict because "a" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [{ line: 7, column: 9 }, { line: 10, column: 9 }], }, ]); @@ -250,17 +250,17 @@ describe('Validate: Overlapping fields can be merged', () => { `).to.deep.equal([ { message: - 'Fields "x" conflict because a and b are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "x" conflict because "a" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [{ line: 18, column: 9 }, { line: 21, column: 9 }], }, { message: - 'Fields "x" conflict because c and a are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "x" conflict because "c" and "a" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [{ line: 14, column: 11 }, { line: 18, column: 9 }], }, { message: - 'Fields "x" conflict because c and b are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "x" conflict because "c" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [{ line: 14, column: 11 }, { line: 21, column: 9 }], }, ]); @@ -279,7 +279,7 @@ describe('Validate: Overlapping fields can be merged', () => { `).to.deep.equal([ { message: - 'Fields "field" conflict because subfields "x" conflict because a and b are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "field" conflict because subfields "x" conflict because "a" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [ { line: 3, column: 9 }, { line: 4, column: 11 }, @@ -305,7 +305,7 @@ describe('Validate: Overlapping fields can be merged', () => { `).to.deep.equal([ { message: - 'Fields "field" conflict because subfields "x" conflict because a and b are different fields and subfields "y" conflict because c and d are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "field" conflict because subfields "x" conflict because "a" and "b" are different fields and subfields "y" conflict because "c" and "d" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [ { line: 3, column: 9 }, { line: 4, column: 11 }, @@ -335,7 +335,7 @@ describe('Validate: Overlapping fields can be merged', () => { `).to.deep.equal([ { message: - 'Fields "field" conflict because subfields "deepField" conflict because subfields "x" conflict because a and b are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "field" conflict because subfields "deepField" conflict because subfields "x" conflict because "a" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [ { line: 3, column: 9 }, { line: 4, column: 11 }, @@ -368,7 +368,7 @@ describe('Validate: Overlapping fields can be merged', () => { `).to.deep.equal([ { message: - 'Fields "deepField" conflict because subfields "x" conflict because a and b are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "deepField" conflict because subfields "x" conflict because "a" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [ { line: 4, column: 11 }, { line: 5, column: 13 }, @@ -407,7 +407,7 @@ describe('Validate: Overlapping fields can be merged', () => { `).to.deep.equal([ { message: - 'Fields "deeperField" conflict because subfields "x" conflict because a and b are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "deeperField" conflict because subfields "x" conflict because "a" and "b" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [ { line: 12, column: 11 }, { line: 13, column: 13 }, @@ -445,7 +445,7 @@ describe('Validate: Overlapping fields can be merged', () => { `).to.deep.equal([ { message: - 'Fields "field" conflict because subfields "x" conflict because a and b are different fields and subfields "y" conflict because c and d are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "field" conflict because subfields "x" conflict because "a" and "b" are different fields and subfields "y" conflict because "c" and "d" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [ { line: 3, column: 9 }, { line: 11, column: 9 }, @@ -559,7 +559,7 @@ describe('Validate: Overlapping fields can be merged', () => { ).to.deep.equal([ { message: - 'Fields "scalar" conflict because they return conflicting types Int and String!. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "scalar" conflict because they return conflicting types "Int" and "String!". Use different aliases on the fields to fetch both if this was intentional.', locations: [{ line: 5, column: 17 }, { line: 8, column: 17 }], }, ]); @@ -608,7 +608,7 @@ describe('Validate: Overlapping fields can be merged', () => { ).to.deep.equal([ { message: - 'Fields "scalar" conflict because they return conflicting types Int and String. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "scalar" conflict because they return conflicting types "Int" and "String". Use different aliases on the fields to fetch both if this was intentional.', locations: [{ line: 5, column: 17 }, { line: 8, column: 17 }], }, ]); @@ -664,7 +664,7 @@ describe('Validate: Overlapping fields can be merged', () => { ).to.deep.equal([ { message: - 'Fields "other" conflict because subfields "scalar" conflict because scalar and unrelatedField are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "other" conflict because subfields "scalar" conflict because "scalar" and "unrelatedField" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [ { line: 31, column: 13 }, { line: 39, column: 13 }, @@ -693,7 +693,7 @@ describe('Validate: Overlapping fields can be merged', () => { ).to.deep.equal([ { message: - 'Fields "scalar" conflict because they return conflicting types String! and String. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "scalar" conflict because they return conflicting types "String!" and "String". Use different aliases on the fields to fetch both if this was intentional.', locations: [{ line: 5, column: 17 }, { line: 8, column: 17 }], }, ]); @@ -721,7 +721,7 @@ describe('Validate: Overlapping fields can be merged', () => { ).to.deep.equal([ { message: - 'Fields "box" conflict because they return conflicting types [StringBox] and StringBox. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "box" conflict because they return conflicting types "[StringBox]" and "StringBox". Use different aliases on the fields to fetch both if this was intentional.', locations: [{ line: 5, column: 17 }, { line: 10, column: 17 }], }, ]); @@ -747,7 +747,7 @@ describe('Validate: Overlapping fields can be merged', () => { ).to.deep.equal([ { message: - 'Fields "box" conflict because they return conflicting types StringBox and [StringBox]. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "box" conflict because they return conflicting types "StringBox" and "[StringBox]". Use different aliases on the fields to fetch both if this was intentional.', locations: [{ line: 5, column: 17 }, { line: 10, column: 17 }], }, ]); @@ -776,7 +776,7 @@ describe('Validate: Overlapping fields can be merged', () => { ).to.deep.equal([ { message: - 'Fields "val" conflict because scalar and unrelatedField are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "val" conflict because "scalar" and "unrelatedField" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [{ line: 6, column: 19 }, { line: 7, column: 19 }], }, ]); @@ -804,7 +804,7 @@ describe('Validate: Overlapping fields can be merged', () => { ).to.deep.equal([ { message: - 'Fields "box" conflict because subfields "scalar" conflict because they return conflicting types String and Int. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "box" conflict because subfields "scalar" conflict because they return conflicting types "String" and "Int". Use different aliases on the fields to fetch both if this was intentional.', locations: [ { line: 5, column: 17 }, { line: 6, column: 19 }, @@ -891,7 +891,7 @@ describe('Validate: Overlapping fields can be merged', () => { ).to.deep.equal([ { message: - 'Fields "edges" conflict because subfields "node" conflict because subfields "id" conflict because name and id are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "edges" conflict because subfields "node" conflict because subfields "id" conflict because "name" and "id" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [ { line: 5, column: 15 }, { line: 6, column: 17 }, @@ -976,7 +976,7 @@ describe('Validate: Overlapping fields can be merged', () => { `).to.deep.equal([ { message: - 'Fields "fido" conflict because name and nickname are different fields. Use different aliases on the fields to fetch both if this was intentional.', + 'Fields "fido" conflict because "name" and "nickname" are different fields. Use different aliases on the fields to fetch both if this was intentional.', locations: [{ line: 4, column: 9 }, { line: 5, column: 9 }], }, ]); diff --git a/src/validation/__tests__/PossibleTypeExtensions-test.js b/src/validation/__tests__/PossibleTypeExtensions-test.js index 45f6b2039e..2dd2406852 100644 --- a/src/validation/__tests__/PossibleTypeExtensions-test.js +++ b/src/validation/__tests__/PossibleTypeExtensions-test.js @@ -135,27 +135,27 @@ describe('Validate: Possible type extensions', () => { extend scalar FooInputObject @dummy `).to.deep.equal([ { - message: 'Cannot extend non-scalar type "FooScalar".', + message: 'Cannot extend non-object type "FooScalar".', locations: [{ line: 2, column: 7 }, { line: 9, column: 7 }], }, { - message: 'Cannot extend non-object type "FooObject".', + message: 'Cannot extend non-interface type "FooObject".', locations: [{ line: 3, column: 7 }, { line: 10, column: 7 }], }, { - message: 'Cannot extend non-interface type "FooInterface".', + message: 'Cannot extend non-union type "FooInterface".', locations: [{ line: 4, column: 7 }, { line: 11, column: 7 }], }, { - message: 'Cannot extend non-union type "FooUnion".', + message: 'Cannot extend non-enum type "FooUnion".', locations: [{ line: 5, column: 7 }, { line: 12, column: 7 }], }, { - message: 'Cannot extend non-enum type "FooEnum".', + message: 'Cannot extend non-input object type "FooEnum".', locations: [{ line: 6, column: 7 }, { line: 13, column: 7 }], }, { - message: 'Cannot extend non-input object type "FooInputObject".', + message: 'Cannot extend non-scalar type "FooInputObject".', locations: [{ line: 7, column: 7 }, { line: 14, column: 7 }], }, ]); @@ -225,27 +225,27 @@ describe('Validate: Possible type extensions', () => { expectSDLErrors(sdl, schema).to.deep.equal([ { - message: 'Cannot extend non-scalar type "FooScalar".', + message: 'Cannot extend non-object type "FooScalar".', locations: [{ line: 2, column: 7 }], }, { - message: 'Cannot extend non-object type "FooObject".', + message: 'Cannot extend non-interface type "FooObject".', locations: [{ line: 3, column: 7 }], }, { - message: 'Cannot extend non-interface type "FooInterface".', + message: 'Cannot extend non-union type "FooInterface".', locations: [{ line: 4, column: 7 }], }, { - message: 'Cannot extend non-union type "FooUnion".', + message: 'Cannot extend non-enum type "FooUnion".', locations: [{ line: 5, column: 7 }], }, { - message: 'Cannot extend non-enum type "FooEnum".', + message: 'Cannot extend non-input object type "FooEnum".', locations: [{ line: 6, column: 7 }], }, { - message: 'Cannot extend non-input object type "FooInputObject".', + message: 'Cannot extend non-scalar type "FooInputObject".', locations: [{ line: 7, column: 7 }], }, ]); diff --git a/src/validation/__tests__/UniqueDirectiveNames-test.js b/src/validation/__tests__/UniqueDirectiveNames-test.js index f14608803e..02207a5d5e 100644 --- a/src/validation/__tests__/UniqueDirectiveNames-test.js +++ b/src/validation/__tests__/UniqueDirectiveNames-test.js @@ -54,7 +54,7 @@ describe('Validate: Unique directive names', () => { directive @foo on SCHEMA `).to.deep.equal([ { - message: 'There can be only one directive named "foo".', + message: 'There can be only one directive named "@foo".', locations: [{ line: 2, column: 18 }, { line: 4, column: 18 }], }, ]); @@ -72,7 +72,7 @@ describe('Validate: Unique directive names', () => { expectSDLErrors('directive @skip on SCHEMA', schema).to.deep.equal([ { message: - 'Directive "skip" already exists in the schema. It cannot be redefined.', + 'Directive "@skip" already exists in the schema. It cannot be redefined.', locations: [{ line: 1, column: 12 }], }, ]); @@ -90,7 +90,7 @@ describe('Validate: Unique directive names', () => { expectSDLErrors('directive @foo on SCHEMA', schema).to.deep.equal([ { message: - 'Directive "foo" already exists in the schema. It cannot be redefined.', + 'Directive "@foo" already exists in the schema. It cannot be redefined.', locations: [{ line: 1, column: 12 }], }, ]); diff --git a/src/validation/__tests__/UniqueDirectivesPerLocation-test.js b/src/validation/__tests__/UniqueDirectivesPerLocation-test.js index 8b2ad100a9..3a02c6ee94 100644 --- a/src/validation/__tests__/UniqueDirectivesPerLocation-test.js +++ b/src/validation/__tests__/UniqueDirectivesPerLocation-test.js @@ -107,7 +107,7 @@ describe('Validate: Directives Are Unique Per Location', () => { `).to.deep.equal([ { message: - 'The directive "directive" can only be used once at this location.', + 'The directive "@directive" can only be used once at this location.', locations: [{ line: 3, column: 15 }, { line: 3, column: 26 }], }, ]); @@ -121,12 +121,12 @@ describe('Validate: Directives Are Unique Per Location', () => { `).to.deep.equal([ { message: - 'The directive "directive" can only be used once at this location.', + 'The directive "@directive" can only be used once at this location.', locations: [{ line: 3, column: 15 }, { line: 3, column: 26 }], }, { message: - 'The directive "directive" can only be used once at this location.', + 'The directive "@directive" can only be used once at this location.', locations: [{ line: 3, column: 15 }, { line: 3, column: 37 }], }, ]); @@ -140,12 +140,12 @@ describe('Validate: Directives Are Unique Per Location', () => { `).to.deep.equal([ { message: - 'The directive "directiveA" can only be used once at this location.', + 'The directive "@directiveA" can only be used once at this location.', locations: [{ line: 3, column: 15 }, { line: 3, column: 39 }], }, { message: - 'The directive "directiveB" can only be used once at this location.', + 'The directive "@directiveB" can only be used once at this location.', locations: [{ line: 3, column: 27 }, { line: 3, column: 51 }], }, ]); @@ -159,12 +159,12 @@ describe('Validate: Directives Are Unique Per Location', () => { `).to.deep.equal([ { message: - 'The directive "directive" can only be used once at this location.', + 'The directive "@directive" can only be used once at this location.', locations: [{ line: 2, column: 29 }, { line: 2, column: 40 }], }, { message: - 'The directive "directive" can only be used once at this location.', + 'The directive "@directive" can only be used once at this location.', locations: [{ line: 3, column: 15 }, { line: 3, column: 26 }], }, ]); @@ -195,62 +195,62 @@ describe('Validate: Directives Are Unique Per Location', () => { `).to.deep.equal([ { message: - 'The directive "nonRepeatable" can only be used once at this location.', + 'The directive "@nonRepeatable" can only be used once at this location.', locations: [{ line: 5, column: 14 }, { line: 5, column: 29 }], }, { message: - 'The directive "nonRepeatable" can only be used once at this location.', + 'The directive "@nonRepeatable" can only be used once at this location.', locations: [{ line: 6, column: 21 }, { line: 6, column: 36 }], }, { message: - 'The directive "nonRepeatable" can only be used once at this location.', + 'The directive "@nonRepeatable" can only be used once at this location.', locations: [{ line: 8, column: 25 }, { line: 8, column: 40 }], }, { message: - 'The directive "nonRepeatable" can only be used once at this location.', + 'The directive "@nonRepeatable" can only be used once at this location.', locations: [{ line: 9, column: 32 }, { line: 9, column: 47 }], }, { message: - 'The directive "nonRepeatable" can only be used once at this location.', + 'The directive "@nonRepeatable" can only be used once at this location.', locations: [{ line: 11, column: 23 }, { line: 11, column: 38 }], }, { message: - 'The directive "nonRepeatable" can only be used once at this location.', + 'The directive "@nonRepeatable" can only be used once at this location.', locations: [{ line: 12, column: 30 }, { line: 12, column: 45 }], }, { message: - 'The directive "nonRepeatable" can only be used once at this location.', + 'The directive "@nonRepeatable" can only be used once at this location.', locations: [{ line: 14, column: 31 }, { line: 14, column: 46 }], }, { message: - 'The directive "nonRepeatable" can only be used once at this location.', + 'The directive "@nonRepeatable" can only be used once at this location.', locations: [{ line: 15, column: 38 }, { line: 15, column: 53 }], }, { message: - 'The directive "nonRepeatable" can only be used once at this location.', + 'The directive "@nonRepeatable" can only be used once at this location.', locations: [{ line: 17, column: 23 }, { line: 17, column: 38 }], }, { message: - 'The directive "nonRepeatable" can only be used once at this location.', + 'The directive "@nonRepeatable" can only be used once at this location.', locations: [{ line: 18, column: 30 }, { line: 18, column: 45 }], }, { message: - 'The directive "nonRepeatable" can only be used once at this location.', + 'The directive "@nonRepeatable" can only be used once at this location.', locations: [{ line: 20, column: 23 }, { line: 20, column: 38 }], }, { message: - 'The directive "nonRepeatable" can only be used once at this location.', + 'The directive "@nonRepeatable" can only be used once at this location.', locations: [{ line: 21, column: 30 }, { line: 21, column: 45 }], }, ]); diff --git a/src/validation/__tests__/UniqueVariableNames-test.js b/src/validation/__tests__/UniqueVariableNames-test.js index 1f1202b380..6ce25ac700 100644 --- a/src/validation/__tests__/UniqueVariableNames-test.js +++ b/src/validation/__tests__/UniqueVariableNames-test.js @@ -29,19 +29,19 @@ describe('Validate: Unique variable names', () => { query C($x: Int, $x: Int) { __typename } `).to.deep.equal([ { - message: 'There can be only one variable named "x".', + message: 'There can be only one variable named "$x".', locations: [{ line: 2, column: 16 }, { line: 2, column: 25 }], }, { - message: 'There can be only one variable named "x".', + message: 'There can be only one variable named "$x".', locations: [{ line: 2, column: 16 }, { line: 2, column: 34 }], }, { - message: 'There can be only one variable named "x".', + message: 'There can be only one variable named "$x".', locations: [{ line: 3, column: 16 }, { line: 3, column: 28 }], }, { - message: 'There can be only one variable named "x".', + message: 'There can be only one variable named "$x".', locations: [{ line: 4, column: 16 }, { line: 4, column: 25 }], }, ]); diff --git a/src/validation/__tests__/ValuesOfCorrectType-test.js b/src/validation/__tests__/ValuesOfCorrectType-test.js index dbbec28af8..3e72c6ab8d 100644 --- a/src/validation/__tests__/ValuesOfCorrectType-test.js +++ b/src/validation/__tests__/ValuesOfCorrectType-test.js @@ -165,7 +165,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type String, found 1.', + message: 'Expected value of type "String", found 1.', locations: [{ line: 4, column: 39 }], }, ]); @@ -180,7 +180,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type String, found 1.0.', + message: 'Expected value of type "String", found 1.0.', locations: [{ line: 4, column: 39 }], }, ]); @@ -195,7 +195,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type String, found true.', + message: 'Expected value of type "String", found true.', locations: [{ line: 4, column: 39 }], }, ]); @@ -210,7 +210,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type String, found BAR.', + message: 'Expected value of type "String", found BAR.', locations: [{ line: 4, column: 39 }], }, ]); @@ -227,7 +227,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Int, found "3".', + message: 'Expected value of type "Int", found "3".', locations: [{ line: 4, column: 33 }], }, ]); @@ -242,7 +242,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Int, found 829384293849283498239482938.', + message: 'Expected value of type "Int", found 829384293849283498239482938.', locations: [{ line: 4, column: 33 }], }, ]); @@ -257,7 +257,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Int, found FOO.', + message: 'Expected value of type "Int", found FOO.', locations: [{ line: 4, column: 33 }], }, ]); @@ -272,7 +272,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Int, found 3.0.', + message: 'Expected value of type "Int", found 3.0.', locations: [{ line: 4, column: 33 }], }, ]); @@ -287,7 +287,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Int, found 3.333.', + message: 'Expected value of type "Int", found 3.333.', locations: [{ line: 4, column: 33 }], }, ]); @@ -304,7 +304,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Float, found "3.333".', + message: 'Expected value of type "Float", found "3.333".', locations: [{ line: 4, column: 37 }], }, ]); @@ -319,7 +319,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Float, found true.', + message: 'Expected value of type "Float", found true.', locations: [{ line: 4, column: 37 }], }, ]); @@ -334,7 +334,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Float, found FOO.', + message: 'Expected value of type "Float", found FOO.', locations: [{ line: 4, column: 37 }], }, ]); @@ -351,7 +351,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Boolean, found 2.', + message: 'Expected value of type "Boolean", found 2.', locations: [{ line: 4, column: 41 }], }, ]); @@ -366,7 +366,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Boolean, found 1.0.', + message: 'Expected value of type "Boolean", found 1.0.', locations: [{ line: 4, column: 41 }], }, ]); @@ -381,7 +381,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Boolean, found "true".', + message: 'Expected value of type "Boolean", found "true".', locations: [{ line: 4, column: 41 }], }, ]); @@ -396,7 +396,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Boolean, found TRUE.', + message: 'Expected value of type "Boolean", found TRUE.', locations: [{ line: 4, column: 41 }], }, ]); @@ -413,7 +413,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type ID, found 1.0.', + message: 'Expected value of type "ID", found 1.0.', locations: [{ line: 4, column: 31 }], }, ]); @@ -428,7 +428,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type ID, found true.', + message: 'Expected value of type "ID", found true.', locations: [{ line: 4, column: 31 }], }, ]); @@ -443,7 +443,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type ID, found SOMETHING.', + message: 'Expected value of type "ID", found SOMETHING.', locations: [{ line: 4, column: 31 }], }, ]); @@ -460,7 +460,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type DogCommand, found 2.', + message: 'Expected value of type "DogCommand", found 2.', locations: [{ line: 4, column: 41 }], }, ]); @@ -475,7 +475,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type DogCommand, found 1.0.', + message: 'Expected value of type "DogCommand", found 1.0.', locations: [{ line: 4, column: 41 }], }, ]); @@ -491,7 +491,7 @@ describe('Validate: Values of correct type', () => { `).to.deep.equal([ { message: - 'Expected type DogCommand, found "SIT". Did you mean the enum value SIT?', + 'Expected value of type "DogCommand", found "SIT". Did you mean the enum value "SIT"?', locations: [{ line: 4, column: 41 }], }, ]); @@ -506,7 +506,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type DogCommand, found true.', + message: 'Expected value of type "DogCommand", found true.', locations: [{ line: 4, column: 41 }], }, ]); @@ -521,7 +521,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type DogCommand, found JUGGLE.', + message: 'Expected value of type "DogCommand", found JUGGLE.', locations: [{ line: 4, column: 41 }], }, ]); @@ -537,7 +537,7 @@ describe('Validate: Values of correct type', () => { `).to.deep.equal([ { message: - 'Expected type DogCommand, found sit. Did you mean the enum value SIT?', + 'Expected value of type "DogCommand", found sit. Did you mean the enum value "SIT"?', locations: [{ line: 4, column: 41 }], }, ]); @@ -596,7 +596,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type String, found 2.', + message: 'Expected value of type "String", found 2.', locations: [{ line: 4, column: 55 }], }, ]); @@ -611,7 +611,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type [String], found 1.', + message: 'Expected value of type "[String]", found 1.', locations: [{ line: 4, column: 47 }], }, ]); @@ -730,11 +730,11 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Int!, found "two".', + message: 'Expected value of type "Int!", found "two".', locations: [{ line: 4, column: 32 }], }, { - message: 'Expected type Int!, found "one".', + message: 'Expected value of type "Int!", found "one".', locations: [{ line: 4, column: 45 }], }, ]); @@ -749,7 +749,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Int!, found "one".', + message: 'Expected value of type "Int!", found "one".', locations: [{ line: 4, column: 32 }], }, ]); @@ -764,7 +764,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Int!, found null.', + message: 'Expected value of type "Int!", found null.', locations: [{ line: 4, column: 32 }], }, ]); @@ -856,7 +856,7 @@ describe('Validate: Values of correct type', () => { `).to.deep.equal([ { message: - 'Field ComplexInput.requiredField of required type Boolean! was not provided.', + 'Field "ComplexInput.requiredField" of required type "Boolean!" was not provided.', locations: [{ line: 4, column: 41 }], }, ]); @@ -874,7 +874,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type String, found 2.', + message: 'Expected value of type "String", found 2.', locations: [{ line: 5, column: 40 }], }, ]); @@ -892,7 +892,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Boolean!, found null.', + message: 'Expected value of type "Boolean!", found null.', locations: [{ line: 6, column: 29 }], }, ]); @@ -911,7 +911,7 @@ describe('Validate: Values of correct type', () => { `).to.deep.equal([ { message: - 'Field "unknownField" is not defined by type ComplexInput. Did you mean nonNullField, intField, or booleanField?', + 'Field "unknownField" is not defined by type "ComplexInput". Did you mean "nonNullField", "intField", or "booleanField"?', locations: [{ line: 6, column: 15 }], }, ]); @@ -927,7 +927,7 @@ describe('Validate: Values of correct type', () => { expectedErrors.to.deep.equal([ { message: - 'Expected type Invalid, found 123; Invalid scalar is always invalid: 123', + 'Expected value of type "Invalid", found 123; Invalid scalar is always invalid: 123', locations: [{ line: 3, column: 27 }], }, ]); @@ -973,11 +973,11 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Boolean!, found "yes".', + message: 'Expected value of type "Boolean!", found "yes".', locations: [{ line: 3, column: 28 }], }, { - message: 'Expected type Boolean!, found ENUM.', + message: 'Expected value of type "Boolean!", found ENUM.', locations: [{ line: 4, column: 28 }], }, ]); @@ -1021,15 +1021,15 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Int!, found null.', + message: 'Expected value of type "Int!", found null.', locations: [{ line: 3, column: 22 }], }, { - message: 'Expected type String!, found null.', + message: 'Expected value of type "String!", found null.', locations: [{ line: 4, column: 25 }], }, { - message: 'Expected type Boolean!, found null.', + message: 'Expected value of type "Boolean!", found null.', locations: [{ line: 5, column: 47 }], }, ]); @@ -1046,15 +1046,15 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Int, found "one".', + message: 'Expected value of type "Int", found "one".', locations: [{ line: 3, column: 21 }], }, { - message: 'Expected type String, found 4.', + message: 'Expected value of type "String", found 4.', locations: [{ line: 4, column: 24 }], }, { - message: 'Expected type ComplexInput, found "notverycomplex".', + message: 'Expected value of type "ComplexInput", found "notverycomplex".', locations: [{ line: 5, column: 30 }], }, ]); @@ -1069,11 +1069,11 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type Boolean!, found 123.', + message: 'Expected value of type "Boolean!", found 123.', locations: [{ line: 3, column: 47 }], }, { - message: 'Expected type Int, found "abc".', + message: 'Expected value of type "Int", found "abc".', locations: [{ line: 3, column: 62 }], }, ]); @@ -1087,7 +1087,7 @@ describe('Validate: Values of correct type', () => { `).to.deep.equal([ { message: - 'Field ComplexInput.requiredField of required type Boolean! was not provided.', + 'Field "ComplexInput.requiredField" of required type "Boolean!" was not provided.', locations: [{ line: 2, column: 55 }], }, ]); @@ -1100,7 +1100,7 @@ describe('Validate: Values of correct type', () => { } `).to.deep.equal([ { - message: 'Expected type String, found 2.', + message: 'Expected value of type "String", found 2.', locations: [{ line: 2, column: 50 }], }, ]); diff --git a/src/validation/__tests__/validation-test.js b/src/validation/__tests__/validation-test.js index e5196e16fd..4571b0f470 100644 --- a/src/validation/__tests__/validation-test.js +++ b/src/validation/__tests__/validation-test.js @@ -41,7 +41,7 @@ describe('Validate: Supports full validation', () => { { locations: [{ line: 3, column: 25 }], message: - 'Expected type Invalid, found "bad value"; Invalid scalar is always invalid: "bad value"', + 'Expected value of type "Invalid", found "bad value"; Invalid scalar is always invalid: "bad value"', }, ]); }); diff --git a/src/validation/rules/ExecutableDefinitions.js b/src/validation/rules/ExecutableDefinitions.js index 2b2e1d4380..0be6ebb0d6 100644 --- a/src/validation/rules/ExecutableDefinitions.js +++ b/src/validation/rules/ExecutableDefinitions.js @@ -25,7 +25,7 @@ export function ExecutableDefinitions( definition.kind === Kind.SCHEMA_DEFINITION || definition.kind === Kind.SCHEMA_EXTENSION ? 'schema' - : definition.name.value; + : '"' + definition.name.value + '"'; context.reportError( new GraphQLError( `The ${defName} definition is not executable.`, diff --git a/src/validation/rules/KnownArgumentNames.js b/src/validation/rules/KnownArgumentNames.js index 61d3e1d99a..c3f60f4fbb 100644 --- a/src/validation/rules/KnownArgumentNames.js +++ b/src/validation/rules/KnownArgumentNames.js @@ -35,7 +35,7 @@ export function KnownArgumentNames(context: ValidationContext): ASTVisitor { const suggestions = suggestionList(argName, knownArgsNames); context.reportError( new GraphQLError( - `Unknown argument "${argName}" on field "${fieldDef.name}" of type "${parentType.name}".` + + `Unknown argument "${argName}" on field "${parentType.name}.${fieldDef.name}".` + didYouMean(suggestions.map(x => `"${x}"`)), argNode, ), diff --git a/src/validation/rules/KnownDirectives.js b/src/validation/rules/KnownDirectives.js index f1c40f4626..5177b24172 100644 --- a/src/validation/rules/KnownDirectives.js +++ b/src/validation/rules/KnownDirectives.js @@ -46,7 +46,7 @@ export function KnownDirectives( if (!locations) { context.reportError( - new GraphQLError(`Unknown directive "${name}".`, node), + new GraphQLError(`Unknown directive "@${name}".`, node), ); return; } @@ -55,7 +55,7 @@ export function KnownDirectives( if (candidateLocation && locations.indexOf(candidateLocation) === -1) { context.reportError( new GraphQLError( - `Directive "${name}" may not be used on ${candidateLocation}.`, + `Directive "@${name}" may not be used on ${candidateLocation}.`, node, ), ); diff --git a/src/validation/rules/NoFragmentCycles.js b/src/validation/rules/NoFragmentCycles.js index 74d171a34a..2ab1ddae03 100644 --- a/src/validation/rules/NoFragmentCycles.js +++ b/src/validation/rules/NoFragmentCycles.js @@ -56,12 +56,15 @@ export function NoFragmentCycles(context: ASTValidationContext): ASTVisitor { } } else { const cyclePath = spreadPath.slice(cycleIndex); - const viaNames = cyclePath.slice(0, -1).map(s => s.name.value); + const viaPath = cyclePath + .slice(0, -1) + .map(s => '"' + s.name.value + '"') + .join(', '); context.reportError( new GraphQLError( `Cannot spread fragment "${spreadName}" within itself` + - (viaNames.length > 0 ? ` via ${viaNames.join(', ')}.` : '.'), + (viaPath !== '' ? ` via ${viaPath}.` : '.'), cyclePath, ), ); diff --git a/src/validation/rules/OverlappingFieldsCanBeMerged.js b/src/validation/rules/OverlappingFieldsCanBeMerged.js index e7a6581091..4643b313e6 100644 --- a/src/validation/rules/OverlappingFieldsCanBeMerged.js +++ b/src/validation/rules/OverlappingFieldsCanBeMerged.js @@ -584,7 +584,7 @@ function findConflict( const name2 = node2.name.value; if (name1 !== name2) { return [ - [responseName, `${name1} and ${name2} are different fields`], + [responseName, `"${name1}" and "${name2}" are different fields`], [node1], [node2], ]; @@ -604,7 +604,9 @@ function findConflict( return [ [ responseName, - `they return conflicting types ${inspect(type1)} and ${inspect(type2)}`, + `they return conflicting types "${inspect(type1)}" and "${inspect( + type2, + )}"`, ], [node1], [node2], diff --git a/src/validation/rules/PossibleTypeExtensions.js b/src/validation/rules/PossibleTypeExtensions.js index a885f29278..5da7efdf30 100644 --- a/src/validation/rules/PossibleTypeExtensions.js +++ b/src/validation/rules/PossibleTypeExtensions.js @@ -60,7 +60,7 @@ export function PossibleTypeExtensions( if (expectedKind) { if (expectedKind !== node.kind) { - const kindStr = extensionKindToTypeName(expectedKind); + const kindStr = extensionKindToTypeName(node.kind); context.reportError( new GraphQLError( `Cannot extend non-${kindStr} type "${typeName}".`, diff --git a/src/validation/rules/UniqueDirectiveNames.js b/src/validation/rules/UniqueDirectiveNames.js index b020bf5f9c..7f281a3b48 100644 --- a/src/validation/rules/UniqueDirectiveNames.js +++ b/src/validation/rules/UniqueDirectiveNames.js @@ -31,7 +31,7 @@ export function UniqueDirectiveNames( if (schema && schema.getDirective(directiveName)) { context.reportError( new GraphQLError( - `Directive "${directiveName}" already exists in the schema. It cannot be redefined.`, + `Directive "@${directiveName}" already exists in the schema. It cannot be redefined.`, node.name, ), ); @@ -41,7 +41,7 @@ export function UniqueDirectiveNames( if (knownDirectiveNames[directiveName]) { context.reportError( new GraphQLError( - `There can be only one directive named "${directiveName}".`, + `There can be only one directive named "@${directiveName}".`, [knownDirectiveNames[directiveName], node.name], ), ); diff --git a/src/validation/rules/UniqueDirectivesPerLocation.js b/src/validation/rules/UniqueDirectivesPerLocation.js index 2e4e2e7fc6..171d11588a 100644 --- a/src/validation/rules/UniqueDirectivesPerLocation.js +++ b/src/validation/rules/UniqueDirectivesPerLocation.js @@ -56,7 +56,7 @@ export function UniqueDirectivesPerLocation( if (knownDirectives[directiveName]) { context.reportError( new GraphQLError( - `The directive "${directiveName}" can only be used once at this location.`, + `The directive "@${directiveName}" can only be used once at this location.`, [knownDirectives[directiveName], directive], ), ); diff --git a/src/validation/rules/UniqueVariableNames.js b/src/validation/rules/UniqueVariableNames.js index 21cae15cfe..6e0643fca8 100644 --- a/src/validation/rules/UniqueVariableNames.js +++ b/src/validation/rules/UniqueVariableNames.js @@ -23,7 +23,7 @@ export function UniqueVariableNames(context: ASTValidationContext): ASTVisitor { if (knownVariableNames[variableName]) { context.reportError( new GraphQLError( - `There can be only one variable named "${variableName}".`, + `There can be only one variable named "$${variableName}".`, [knownVariableNames[variableName], node.variable.name], ), ); diff --git a/src/validation/rules/ValuesOfCorrectType.js b/src/validation/rules/ValuesOfCorrectType.js index 246b380481..312a4c2b6f 100644 --- a/src/validation/rules/ValuesOfCorrectType.js +++ b/src/validation/rules/ValuesOfCorrectType.js @@ -59,7 +59,7 @@ export function ValuesOfCorrectType(context: ValidationContext): ASTVisitor { const typeStr = inspect(fieldDef.type); context.reportError( new GraphQLError( - `Field ${type.name}.${fieldDef.name} of required type ${typeStr} was not provided.`, + `Field "${type.name}.${fieldDef.name}" of required type "${typeStr}" was not provided.`, node, ), ); @@ -76,8 +76,8 @@ export function ValuesOfCorrectType(context: ValidationContext): ASTVisitor { ); context.reportError( new GraphQLError( - `Field "${node.name.value}" is not defined by type ${parentType.name}.` + - didYouMean(suggestions), + `Field "${node.name.value}" is not defined by type "${parentType.name}".` + + didYouMean(suggestions.map(name => '"' + name + '"')), node, ), ); @@ -88,7 +88,7 @@ export function ValuesOfCorrectType(context: ValidationContext): ASTVisitor { if (isNonNullType(type)) { context.reportError( new GraphQLError( - `Expected type ${inspect(type)}, found ${print(node)}.`, + `Expected value of type "${inspect(type)}", found ${print(node)}.`, node, ), ); @@ -118,11 +118,13 @@ function isValidValueNode(context: ValidationContext, node: ValueNode): void { if (isEnumType(type)) { if (node.kind !== Kind.ENUM || !type.getValue(node.value)) { const allNames = type.getValues().map(value => value.name); - const suggestedValues = suggestionList(print(node), allNames); + const suggestedValues = suggestionList(print(node), allNames).map( + x => '"' + x + '"', + ); context.reportError( new GraphQLError( - `Expected type ${type.name}, found ${print(node)}.` + + `Expected value of type "${type.name}", found ${print(node)}.` + didYouMean('the enum value', suggestedValues), node, ), @@ -132,9 +134,10 @@ function isValidValueNode(context: ValidationContext, node: ValueNode): void { } if (!isScalarType(type)) { + const typeStr = inspect(locationType); context.reportError( new GraphQLError( - `Expected type ${inspect(locationType)}, found ${print(node)}.`, + `Expected value of type "${typeStr}", found ${print(node)}.`, node, ), ); @@ -146,18 +149,20 @@ function isValidValueNode(context: ValidationContext, node: ValueNode): void { try { const parseResult = type.parseLiteral(node, undefined /* variables */); if (isInvalid(parseResult)) { + const typeStr = inspect(locationType); context.reportError( new GraphQLError( - `Expected type ${inspect(locationType)}, found ${print(node)}.`, + `Expected value of type "${typeStr}", found ${print(node)}.`, node, ), ); } } catch (error) { + const typeStr = inspect(locationType); // Ensure a reference to the original error is maintained. context.reportError( new GraphQLError( - `Expected type ${inspect(locationType)}, found ${print(node)}; ` + + `Expected value of type "${typeStr}", found ${print(node)}; ` + error.message, node, undefined,