From 80ca852ebd113ed4c39218244a6e863332912ae8 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 8 Mar 2018 20:17:32 +0200 Subject: [PATCH] Error: make 'path' and 'locations' enumerable only if present Also cleanup tests from 'undefined' and 'containSubset'. --- src/error/GraphQLError.js | 4 +- src/execution/__tests__/executor-test.js | 187 ++++++++---------- src/execution/__tests__/lists-test.js | 14 +- src/execution/__tests__/mutations-test.js | 48 ++--- src/execution/__tests__/sync-test.js | 23 +-- src/execution/__tests__/variables-test.js | 15 -- src/subscription/__tests__/subscribe-test.js | 2 - src/type/__tests__/enumType-test.js | 8 - src/type/__tests__/introspection-test.js | 2 +- src/type/__tests__/validation-test.js | 139 ++++++------- .../__tests__/isValidLiteralValue-test.js | 1 - .../__tests__/ExecutableDefinitions-test.js | 1 - .../__tests__/FieldsOnCorrectType-test.js | 1 - .../FragmentsOnCompositeTypes-test.js | 2 - .../__tests__/KnownArgumentNames-test.js | 2 - .../__tests__/KnownDirectives-test.js | 2 - .../__tests__/KnownFragmentNames-test.js | 1 - .../__tests__/KnownTypeNames-test.js | 1 - .../__tests__/LoneAnonymousOperation-test.js | 1 - .../__tests__/NoFragmentCycles-test.js | 15 -- .../__tests__/NoUndefinedVariables-test.js | 1 - .../__tests__/NoUnusedFragments-test.js | 1 - .../__tests__/NoUnusedVariables-test.js | 1 - .../OverlappingFieldsCanBeMerged-test.js | 25 --- .../__tests__/PossibleFragmentSpreads-test.js | 2 - .../ProvidedNonNullArguments-test.js | 2 - src/validation/__tests__/ScalarLeafs-test.js | 2 - .../SingleFieldSubscriptions-test.js | 4 - .../__tests__/UniqueArgumentNames-test.js | 1 - .../UniqueDirectivesPerLocation-test.js | 1 - .../__tests__/UniqueFragmentNames-test.js | 1 - .../__tests__/UniqueInputFieldNames-test.js | 1 - .../__tests__/UniqueOperationNames-test.js | 1 - .../__tests__/UniqueVariableNames-test.js | 1 - .../__tests__/ValuesOfCorrectType-test.js | 3 - .../__tests__/VariablesAreInputTypes-test.js | 3 - .../VariablesDefaultValueAllowed-test.js | 1 - .../VariablesInAllowedPosition-test.js | 8 - src/validation/__tests__/harness.js | 3 +- src/validation/__tests__/validation-test.js | 1 - 40 files changed, 183 insertions(+), 349 deletions(-) diff --git a/src/error/GraphQLError.js b/src/error/GraphQLError.js index b10df8c7708..926152cf0f1 100644 --- a/src/error/GraphQLError.js +++ b/src/error/GraphQLError.js @@ -151,7 +151,7 @@ export function GraphQLError( // eslint-disable-line no-redeclare // By being enumerable, JSON.stringify will include `locations` in the // resulting output. This ensures that the simplest possible GraphQL // service adheres to the spec. - enumerable: true, + enumerable: Boolean(_locations), }, path: { // Coercing falsey values to undefined ensures they will not be included @@ -160,7 +160,7 @@ export function GraphQLError( // eslint-disable-line no-redeclare // By being enumerable, JSON.stringify will include `path` in the // resulting output. This ensures that the simplest possible GraphQL // service adheres to the spec. - enumerable: true, + enumerable: Boolean(path), }, nodes: { value: _nodes || undefined, diff --git a/src/execution/__tests__/executor-test.js b/src/execution/__tests__/executor-test.js index d3178d6891e..49f7dcec2df 100644 --- a/src/execution/__tests__/executor-test.js +++ b/src/execution/__tests__/executor-test.js @@ -8,7 +8,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import { execute } from '../execute'; -import { formatError } from '../../error'; import { parse } from '../../language'; import { GraphQLSchema, @@ -461,78 +460,79 @@ describe('Execute: Handles basic execution tasks', () => { const result = await execute(schema, ast, data); - expect(result.data).to.deep.equal({ - sync: 'sync', - syncError: null, - syncRawError: null, - syncReturnError: null, - syncReturnErrorList: ['sync0', null, 'sync2', null], - async: 'async', - asyncReject: null, - asyncRawReject: null, - asyncEmptyReject: null, - asyncError: null, - asyncRawError: null, - asyncReturnError: null, - }); - - expect(result.errors && result.errors.map(formatError)).to.deep.equal([ - { - message: 'Error getting syncError', - locations: [{ line: 3, column: 7 }], - path: ['syncError'], - }, - { - message: 'Error getting syncRawError', - locations: [{ line: 4, column: 7 }], - path: ['syncRawError'], - }, - { - message: 'Error getting syncReturnError', - locations: [{ line: 5, column: 7 }], - path: ['syncReturnError'], - }, - { - message: 'Error getting syncReturnErrorList1', - locations: [{ line: 6, column: 7 }], - path: ['syncReturnErrorList', 1], - }, - { - message: 'Error getting syncReturnErrorList3', - locations: [{ line: 6, column: 7 }], - path: ['syncReturnErrorList', 3], - }, - { - message: 'Error getting asyncReject', - locations: [{ line: 8, column: 7 }], - path: ['asyncReject'], - }, - { - message: 'Error getting asyncRawReject', - locations: [{ line: 9, column: 7 }], - path: ['asyncRawReject'], - }, - { - message: 'An unknown error occurred.', - locations: [{ line: 10, column: 7 }], - path: ['asyncEmptyReject'], - }, - { - message: 'Error getting asyncError', - locations: [{ line: 11, column: 7 }], - path: ['asyncError'], - }, - { - message: 'Error getting asyncRawError', - locations: [{ line: 12, column: 7 }], - path: ['asyncRawError'], - }, - { - message: 'Error getting asyncReturnError', - locations: [{ line: 13, column: 7 }], - path: ['asyncReturnError'], + expect(result).to.deep.equal({ + data: { + sync: 'sync', + syncError: null, + syncRawError: null, + syncReturnError: null, + syncReturnErrorList: ['sync0', null, 'sync2', null], + async: 'async', + asyncReject: null, + asyncRawReject: null, + asyncEmptyReject: null, + asyncError: null, + asyncRawError: null, + asyncReturnError: null, }, - ]); + errors: [ + { + message: 'Error getting syncError', + locations: [{ line: 3, column: 7 }], + path: ['syncError'], + }, + { + message: 'Error getting syncRawError', + locations: [{ line: 4, column: 7 }], + path: ['syncRawError'], + }, + { + message: 'Error getting syncReturnError', + locations: [{ line: 5, column: 7 }], + path: ['syncReturnError'], + }, + { + message: 'Error getting syncReturnErrorList1', + locations: [{ line: 6, column: 7 }], + path: ['syncReturnErrorList', 1], + }, + { + message: 'Error getting syncReturnErrorList3', + locations: [{ line: 6, column: 7 }], + path: ['syncReturnErrorList', 3], + }, + { + message: 'Error getting asyncReject', + locations: [{ line: 8, column: 7 }], + path: ['asyncReject'], + }, + { + message: 'Error getting asyncRawReject', + locations: [{ line: 9, column: 7 }], + path: ['asyncRawReject'], + }, + { + message: '', + locations: [{ line: 10, column: 7 }], + path: ['asyncEmptyReject'], + }, + { + message: 'Error getting asyncError', + locations: [{ line: 11, column: 7 }], + path: ['asyncError'], + }, + { + message: 'Error getting asyncRawError', + locations: [{ line: 12, column: 7 }], + path: ['asyncRawError'], + }, + { + message: 'Error getting asyncReturnError', + locations: [{ line: 13, column: 7 }], + path: ['asyncReturnError'], + }, + ], + }); }); it('nulls error subtree for promise rejection #1071', async () => { @@ -720,13 +720,7 @@ describe('Execute: Handles basic execution tasks', () => { const result = await execute(schema, ast, data); expect(result).to.deep.equal({ - errors: [ - { - message: 'Must provide an operation.', - locations: undefined, - path: undefined, - }, - ], + errors: [{ message: 'Must provide an operation.' }], }); }); @@ -748,10 +742,7 @@ describe('Execute: Handles basic execution tasks', () => { errors: [ { message: - 'Must provide operation name if query contains ' + - 'multiple operations.', - locations: undefined, - path: undefined, + 'Must provide operation name if query contains multiple operations.', }, ], }); @@ -775,13 +766,7 @@ describe('Execute: Handles basic execution tasks', () => { operationName: 'UnknownExample', }); expect(result).to.deep.equal({ - errors: [ - { - message: 'Unknown operation named "UnknownExample".', - locations: undefined, - path: undefined, - }, - ], + errors: [{ message: 'Unknown operation named "UnknownExample".' }], }); }); @@ -1046,17 +1031,19 @@ describe('Execute: Handles basic execution tasks', () => { }; const result = await execute(schema, query, value); - expect(result.data).to.deep.equal({ - specials: [{ value: 'foo' }, null], - }); - expect(result.errors).to.have.lengthOf(1); - expect(result.errors).to.containSubset([ - { - message: - 'Expected value of type "SpecialType" but got: [object Object].', - locations: [{ line: 1, column: 3 }], + expect(result).to.deep.equal({ + data: { + specials: [{ value: 'foo' }, null], }, - ]); + errors: [ + { + message: + 'Expected value of type "SpecialType" but got: [object Object].', + locations: [{ line: 1, column: 3 }], + path: ['specials', 1], + }, + ], + }); }); it('executes ignoring invalid non-executable definitions', async () => { diff --git a/src/execution/__tests__/lists-test.js b/src/execution/__tests__/lists-test.js index 05e077bf0f4..e6513b10bd0 100644 --- a/src/execution/__tests__/lists-test.js +++ b/src/execution/__tests__/lists-test.js @@ -7,7 +7,6 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; -import { formatError } from '../../error'; import { execute } from '../execute'; import { parse } from '../../language'; import { @@ -48,18 +47,7 @@ function check(testType, testData, expected) { const ast = parse('{ nest { test } }'); const response = await execute(schema, ast, data); - - // Formatting errors for ease of test writing. - let result; - if (response.errors) { - result = { - data: response.data, - errors: response.errors.map(formatError), - }; - } else { - result = response; - } - expect(result).to.deep.equal(expected); + expect(response).to.deep.equal(expected); }; } diff --git a/src/execution/__tests__/mutations-test.js b/src/execution/__tests__/mutations-test.js index d21d0dac4b1..c3a76e92fc1 100644 --- a/src/execution/__tests__/mutations-test.js +++ b/src/execution/__tests__/mutations-test.js @@ -167,33 +167,27 @@ describe('Execute: Handles mutation execution ordering', () => { const result = await execute(schema, parse(doc), new Root(6)); - expect(result.data).to.deep.equal({ - first: { - theNumber: 1, - }, - second: { - theNumber: 2, - }, - third: null, - fourth: { - theNumber: 4, - }, - fifth: { - theNumber: 5, - }, - sixth: null, + expect(result).to.deep.equal({ + data: { + first: { theNumber: 1 }, + second: { theNumber: 2 }, + third: null, + fourth: { theNumber: 4 }, + fifth: { theNumber: 5 }, + sixth: null, + }, + errors: [ + { + message: 'Cannot change the number', + locations: [{ line: 8, column: 7 }], + path: ['third'], + }, + { + message: 'Cannot change the number', + locations: [{ line: 17, column: 7 }], + path: ['sixth'], + }, + ], }); - - expect(result.errors).to.have.length(2); - expect(result.errors).to.containSubset([ - { - message: 'Cannot change the number', - locations: [{ line: 8, column: 7 }], - }, - { - message: 'Cannot change the number', - locations: [{ line: 17, column: 7 }], - }, - ]); }); }); diff --git a/src/execution/__tests__/sync-test.js b/src/execution/__tests__/sync-test.js index bcef44d3606..8d77856fc10 100644 --- a/src/execution/__tests__/sync-test.js +++ b/src/execution/__tests__/sync-test.js @@ -10,6 +10,7 @@ import { describe, it } from 'mocha'; import { graphqlSync } from '../../graphql'; import { execute } from '../execute'; import { parse } from '../../language'; +import { validate } from '../../validation/validate'; import { GraphQLSchema, GraphQLObjectType, GraphQLString } from '../../type'; describe('Execute: synchronously when possible', () => { @@ -52,13 +53,7 @@ describe('Execute: synchronously when possible', () => { rootValue: 'rootValue', }); expect(result).to.deep.equal({ - errors: [ - { - message: 'Must provide an operation.', - locations: undefined, - path: undefined, - }, - ], + errors: [{ message: 'Must provide an operation.' }], }); }); @@ -102,7 +97,7 @@ describe('Execute: synchronously when possible', () => { schema, source: doc, }); - expect(result).to.containSubset({ + expect(result).to.deep.equal({ errors: [ { message: 'Syntax Error: Expected Name, found {', @@ -114,20 +109,12 @@ describe('Execute: synchronously when possible', () => { it('does not return a Promise for validation errors', () => { const doc = 'fragment Example on Query { unknownField }'; + const validationErrors = validate(schema, parse(doc)); const result = graphqlSync({ schema, source: doc, }); - expect(result).to.containSubset({ - errors: [ - { - message: - 'Cannot query field "unknownField" on type "Query". Did you ' + - 'mean "syncField" or "asyncField"?', - locations: [{ line: 1, column: 29 }], - }, - ], - }); + expect(result).to.deep.equal({ errors: validationErrors }); }); it('does not return a Promise for sync execution', () => { diff --git a/src/execution/__tests__/variables-test.js b/src/execution/__tests__/variables-test.js index 378ae541bc2..30850c447b9 100644 --- a/src/execution/__tests__/variables-test.js +++ b/src/execution/__tests__/variables-test.js @@ -270,7 +270,6 @@ describe('Execute: Handles inputs', () => { '{"a":"foo","b":"bar","c":null}; ' + 'Expected non-nullable type String! not to be null at value.c.', locations: [{ line: 2, column: 16 }], - path: undefined, }, ], }); @@ -286,7 +285,6 @@ describe('Execute: Handles inputs', () => { 'Variable "$input" got invalid value "foo bar"; ' + 'Expected type TestInputObject to be an object.', locations: [{ line: 2, column: 16 }], - path: undefined, }, ], }); @@ -302,7 +300,6 @@ describe('Execute: Handles inputs', () => { 'Variable "$input" got invalid value {"a":"foo","b":"bar"}; ' + 'Field value.c of required type String! was not provided.', locations: [{ line: 2, column: 16 }], - path: undefined, }, ], }); @@ -323,14 +320,12 @@ describe('Execute: Handles inputs', () => { 'Variable "$input" got invalid value {"na":{"a":"foo"}}; ' + 'Field value.na.c of required type String! was not provided.', locations: [{ line: 2, column: 18 }], - path: undefined, }, { message: 'Variable "$input" got invalid value {"na":{"a":"foo"}}; ' + 'Field value.nb of required type String! was not provided.', locations: [{ line: 2, column: 18 }], - path: undefined, }, ], }); @@ -350,7 +345,6 @@ describe('Execute: Handles inputs', () => { '{"a":"foo","b":"bar","c":"baz","extra":"dog"}; ' + 'Field "extra" is not defined by type TestInputObject.', locations: [{ line: 2, column: 16 }], - path: undefined, }, ], }); @@ -474,7 +468,6 @@ describe('Execute: Handles inputs', () => { message: 'Variable "$value" of required type "String!" was not provided.', locations: [{ line: 2, column: 16 }], - path: undefined, }, ], }); @@ -495,7 +488,6 @@ describe('Execute: Handles inputs', () => { 'Variable "$value" got invalid value null; ' + 'Expected non-nullable type String! not to be null.', locations: [{ line: 2, column: 16 }], - path: undefined, }, ], }); @@ -563,7 +555,6 @@ describe('Execute: Handles inputs', () => { 'Variable "$value" got invalid value [1,2,3]; Expected type ' + 'String; String cannot represent an array value: [1,2,3]', locations: [{ line: 2, column: 16 }], - path: undefined, }, ], }); @@ -656,7 +647,6 @@ describe('Execute: Handles inputs', () => { 'Variable "$input" got invalid value null; ' + 'Expected non-nullable type [String]! not to be null.', locations: [{ line: 2, column: 16 }], - path: undefined, }, ], }); @@ -721,7 +711,6 @@ describe('Execute: Handles inputs', () => { 'Variable "$input" got invalid value ["A",null,"B"]; ' + 'Expected non-nullable type String! not to be null at value[1].', locations: [{ line: 2, column: 16 }], - path: undefined, }, ], }); @@ -742,7 +731,6 @@ describe('Execute: Handles inputs', () => { 'Variable "$input" got invalid value null; ' + 'Expected non-nullable type [String!]! not to be null.', locations: [{ line: 2, column: 16 }], - path: undefined, }, ], }); @@ -774,7 +762,6 @@ describe('Execute: Handles inputs', () => { 'Variable "$input" got invalid value ["A",null,"B"]; ' + 'Expected non-nullable type String! not to be null at value[1].', locations: [{ line: 2, column: 16 }], - path: undefined, }, ], }); @@ -795,7 +782,6 @@ describe('Execute: Handles inputs', () => { 'Variable "$input" expected value of type "TestType!" which ' + 'cannot be used as an input type.', locations: [{ line: 2, column: 24 }], - path: undefined, }, ], }); @@ -816,7 +802,6 @@ describe('Execute: Handles inputs', () => { 'Variable "$input" expected value of type "UnknownType!" which ' + 'cannot be used as an input type.', locations: [{ line: 2, column: 24 }], - path: undefined, }, ], }); diff --git a/src/subscription/__tests__/subscribe-test.js b/src/subscription/__tests__/subscribe-test.js index 141733de36f..6d9e9f440d3 100644 --- a/src/subscription/__tests__/subscribe-test.js +++ b/src/subscription/__tests__/subscribe-test.js @@ -350,7 +350,6 @@ describe('Subscription Initialization Phase', () => { { message: 'The subscription field "unknownField" is not defined.', locations: [{ line: 3, column: 9 }], - path: undefined, }, ], }); @@ -478,7 +477,6 @@ describe('Subscription Initialization Phase', () => { 'type Int; Int cannot represent non 32-bit signed ' + 'integer value: meow', locations: [{ line: 2, column: 21 }], - path: undefined, }, ], }); diff --git a/src/type/__tests__/enumType-test.js b/src/type/__tests__/enumType-test.js index 075dce39e51..2e88f79ca31 100644 --- a/src/type/__tests__/enumType-test.js +++ b/src/type/__tests__/enumType-test.js @@ -163,7 +163,6 @@ describe('Type System: Enum Values', () => { message: 'Expected type Color, found "GREEN"; Did you mean the enum value GREEN?', locations: [{ line: 1, column: 23 }], - path: undefined, }, ], }); @@ -178,7 +177,6 @@ describe('Type System: Enum Values', () => { message: 'Expected type Color, found GREENISH; Did you mean the enum value GREEN?', locations: [{ line: 1, column: 23 }], - path: undefined, }, ], }); @@ -193,7 +191,6 @@ describe('Type System: Enum Values', () => { message: 'Expected type Color, found green; Did you mean the enum value GREEN?', locations: [{ line: 1, column: 23 }], - path: undefined, }, ], }); @@ -222,7 +219,6 @@ describe('Type System: Enum Values', () => { { message: 'Expected type Color, found 1.', locations: [{ line: 1, column: 23 }], - path: undefined, }, ], }); @@ -236,7 +232,6 @@ describe('Type System: Enum Values', () => { { message: 'Expected type Int, found GREEN.', locations: [{ line: 1, column: 22 }], - path: undefined, }, ], }); @@ -280,7 +275,6 @@ describe('Type System: Enum Values', () => { message: 'Variable "$color" got invalid value 2; Expected type Color.', locations: [{ line: 1, column: 8 }], - path: undefined, }, ], }); @@ -297,7 +291,6 @@ describe('Type System: Enum Values', () => { 'Variable "$color" of type "String!" used in position ' + 'expecting type "Color".', locations: [{ line: 1, column: 8 }, { line: 1, column: 47 }], - path: undefined, }, ], }); @@ -314,7 +307,6 @@ describe('Type System: Enum Values', () => { 'Variable "$color" of type "Int!" used in position ' + 'expecting type "Color".', locations: [{ line: 1, column: 8 }, { line: 1, column: 44 }], - path: undefined, }, ], }); diff --git a/src/type/__tests__/introspection-test.js b/src/type/__tests__/introspection-test.js index 6106bcd1c33..cf39e5a71d3 100644 --- a/src/type/__tests__/introspection-test.js +++ b/src/type/__tests__/introspection-test.js @@ -1198,7 +1198,7 @@ describe('Introspection', () => { } `; - return expect(graphqlSync(schema, request)).to.containSubset({ + return expect(graphqlSync(schema, request)).to.deep.equal({ errors: [ { message: missingFieldArgMessage('__type', 'name', 'String!'), diff --git a/src/type/__tests__/validation-test.js b/src/type/__tests__/validation-test.js index 19f13a336bf..6ea4ac33c12 100644 --- a/src/type/__tests__/validation-test.js +++ b/src/type/__tests__/validation-test.js @@ -186,10 +186,9 @@ describe('Type System: A Schema must have Object root types', () => { test: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Query root type must be provided.', - locations: undefined, }, ]); @@ -202,7 +201,7 @@ describe('Type System: A Schema must have Object root types', () => { test: String } `); - expect(validateSchema(schemaWithDef)).to.containSubset([ + expect(validateSchema(schemaWithDef)).to.deep.equal([ { message: 'Query root type must be provided.', locations: [{ line: 2, column: 7 }], @@ -216,7 +215,7 @@ describe('Type System: A Schema must have Object root types', () => { test: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Query root type must be Object type, it cannot be Query.', locations: [{ line: 2, column: 7 }], @@ -232,7 +231,7 @@ describe('Type System: A Schema must have Object root types', () => { test: String } `); - expect(validateSchema(schemaWithDef)).to.containSubset([ + expect(validateSchema(schemaWithDef)).to.deep.equal([ { message: 'Query root type must be Object type, it cannot be SomeInputObject.', @@ -251,7 +250,7 @@ describe('Type System: A Schema must have Object root types', () => { test: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Mutation root type must be Object type if provided, it cannot be Mutation.', @@ -273,7 +272,7 @@ describe('Type System: A Schema must have Object root types', () => { test: String } `); - expect(validateSchema(schemaWithDef)).to.containSubset([ + expect(validateSchema(schemaWithDef)).to.deep.equal([ { message: 'Mutation root type must be Object type if provided, it cannot be SomeInputObject.', @@ -292,7 +291,7 @@ describe('Type System: A Schema must have Object root types', () => { test: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Subscription root type must be Object type if provided, it cannot be Subscription.', @@ -314,7 +313,7 @@ describe('Type System: A Schema must have Object root types', () => { test: String } `); - expect(validateSchema(schemaWithDef)).to.containSubset([ + expect(validateSchema(schemaWithDef)).to.deep.equal([ { message: 'Subscription root type must be Object type if provided, it cannot be SomeInputObject.', @@ -328,7 +327,7 @@ describe('Type System: A Schema must have Object root types', () => { query: SomeObjectType, directives: ['somedirective'], }); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Expected directive but got: somedirective.', }, @@ -358,7 +357,7 @@ describe('Type System: Objects must have fields', () => { type IncompleteObject `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Type IncompleteObject must define one or more fields.', locations: [{ line: 6, column: 7 }], @@ -371,7 +370,7 @@ describe('Type System: Objects must have fields', () => { fields: {}, }), ); - expect(validateSchema(manualSchema)).to.containSubset([ + expect(validateSchema(manualSchema)).to.deep.equal([ { message: 'Type IncompleteObject must define one or more fields.', }, @@ -385,7 +384,7 @@ describe('Type System: Objects must have fields', () => { }, }), ); - expect(validateSchema(manualSchema2)).to.containSubset([ + expect(validateSchema(manualSchema2)).to.deep.equal([ { message: 'Type IncompleteObject must define one or more fields.', }, @@ -399,7 +398,7 @@ describe('Type System: Objects must have fields', () => { fields: { 'bad-name-with-dashes': { type: GraphQLString } }, }), ); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but ' + @@ -422,7 +421,7 @@ describe('Type System: Objects must have fields', () => { }), allowedLegacyNames: ['__badName'], }); - expect(validateSchema(schemaBad)).to.containSubset([ + expect(validateSchema(schemaBad)).to.deep.equal([ { message: 'Name "__badName" must not begin with "__", which is reserved by ' + @@ -477,7 +476,7 @@ describe('Type System: Fields args must be properly named', () => { }, }); const schema = new GraphQLSchema({ query: QueryType }); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "bad-name-with-dashes" does not.', @@ -516,7 +515,7 @@ describe('Type System: Union types must be valid', () => { union BadUnion `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Union type BadUnion must define one or more member types.', locations: [{ line: 6, column: 7 }], @@ -543,7 +542,7 @@ describe('Type System: Union types must be valid', () => { | TypeB | TypeA `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Union type BadUnion can only include type TypeA once.', locations: [{ line: 15, column: 11 }, { line: 17, column: 11 }], @@ -570,7 +569,7 @@ describe('Type System: Union types must be valid', () => { | String | TypeB `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Union type BadUnion can only include Object types, ' + @@ -592,7 +591,7 @@ describe('Type System: Union types must be valid', () => { const badSchema = schemaWithFieldType( new GraphQLUnionType({ name: 'BadUnion', types: [memberType] }), ); - expect(validateSchema(badSchema)).to.containSubset([ + expect(validateSchema(badSchema)).to.deep.equal([ { message: 'Union type BadUnion can only include Object types, ' + @@ -625,7 +624,7 @@ describe('Type System: Input Objects must have fields', () => { input SomeInputObject `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Input Object type SomeInputObject must define one or more fields.', @@ -652,7 +651,7 @@ describe('Type System: Input Objects must have fields', () => { goodInputObject: SomeInputObject } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'The type of SomeInputObject.badObject must be Input Type but got: SomeObject.', @@ -676,7 +675,7 @@ describe('Type System: Enum types must be well defined', () => { enum SomeEnum `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Enum type SomeEnum must define one or more values.', locations: [{ line: 6, column: 7 }], @@ -695,7 +694,7 @@ describe('Type System: Enum types must be well defined', () => { SOME_VALUE } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Enum type SomeEnum can include value SOME_VALUE only once.', locations: [{ line: 7, column: 9 }, { line: 8, column: 9 }], @@ -716,7 +715,7 @@ describe('Type System: Enum types must be well defined', () => { } const schema1 = schemaWithEnum('#value'); - expect(validateSchema(schema1)).to.containSubset([ + expect(validateSchema(schema1)).to.deep.equal([ { message: 'Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "#value" does not.', @@ -724,7 +723,7 @@ describe('Type System: Enum types must be well defined', () => { ]); const schema2 = schemaWithEnum('1value'); - expect(validateSchema(schema2)).to.containSubset([ + expect(validateSchema(schema2)).to.deep.equal([ { message: 'Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "1value" does not.', @@ -732,7 +731,7 @@ describe('Type System: Enum types must be well defined', () => { ]); const schema3 = schemaWithEnum('KEBAB-CASE'); - expect(validateSchema(schema3)).to.containSubset([ + expect(validateSchema(schema3)).to.deep.equal([ { message: 'Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "KEBAB-CASE" does not.', @@ -740,17 +739,17 @@ describe('Type System: Enum types must be well defined', () => { ]); const schema4 = schemaWithEnum('true'); - expect(validateSchema(schema4)).to.containSubset([ + expect(validateSchema(schema4)).to.deep.equal([ { message: 'Enum type SomeEnum cannot include value: true.' }, ]); const schema5 = schemaWithEnum('false'); - expect(validateSchema(schema5)).to.containSubset([ + expect(validateSchema(schema5)).to.deep.equal([ { message: 'Enum type SomeEnum cannot include value: false.' }, ]); const schema6 = schemaWithEnum('null'); - expect(validateSchema(schema6)).to.containSubset([ + expect(validateSchema(schema6)).to.deep.equal([ { message: 'Enum type SomeEnum cannot include value: null.' }, ]); }); @@ -784,7 +783,7 @@ describe('Type System: Object fields must have output types', () => { it('rejects an empty Object field type', () => { const schema = schemaWithObjectFieldOfType(undefined); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'The type of BadObject.badField must be Output Type but got: undefined.', @@ -795,11 +794,9 @@ describe('Type System: Object fields must have output types', () => { notOutputTypes.forEach(type => { it(`rejects a non-output type as an Object field type: ${type}`, () => { const schema = schemaWithObjectFieldOfType(type); - expect(validateSchema(schema)).to.containSubset([ - { - message: `The type of BadObject.badField must be Output Type but got: ${type}.`, - }, - ]); + expect(validateSchema(schema)).to.deep.include({ + message: `The type of BadObject.badField must be Output Type but got: ${type}.`, + }); }); }); @@ -813,7 +810,7 @@ describe('Type System: Object fields must have output types', () => { field: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'The type of Query.field must be Output Type but got: [SomeInputObject].', @@ -854,7 +851,7 @@ describe('Type System: Objects can only implement unique interfaces', () => { field: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Type BadObject must only implement Interface types, it cannot implement SomeInputObject.', @@ -877,7 +874,7 @@ describe('Type System: Objects can only implement unique interfaces', () => { field: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Type AnotherObject can only implement AnotherInterface once.', locations: [{ line: 10, column: 37 }, { line: 10, column: 56 }], @@ -903,7 +900,7 @@ describe('Type System: Objects can only implement unique interfaces', () => { schema, parse('extend type AnotherObject implements AnotherInterface'), ); - expect(validateSchema(extendedSchema)).to.containSubset([ + expect(validateSchema(extendedSchema)).to.deep.equal([ { message: 'Type AnotherObject can only implement AnotherInterface once.', locations: [{ line: 10, column: 37 }, { line: 1, column: 38 }], @@ -935,7 +932,7 @@ describe('Type System: Interface extensions should be valid', () => { } `), ); - expect(validateSchema(extendedSchema)).to.containSubset([ + expect(validateSchema(extendedSchema)).to.deep.equal([ { message: 'Interface field AnotherInterface.newField expected but AnotherObject does not provide it.', @@ -970,7 +967,7 @@ describe('Type System: Interface extensions should be valid', () => { } `), ); - expect(validateSchema(extendedSchema)).to.containSubset([ + expect(validateSchema(extendedSchema)).to.deep.equal([ { message: 'Interface field argument AnotherInterface.newField(test:) expected but AnotherObject.newField does not provide it.', @@ -1013,7 +1010,7 @@ describe('Type System: Interface extensions should be valid', () => { } `), ); - expect(validateSchema(extendedSchema)).to.containSubset([ + expect(validateSchema(extendedSchema)).to.deep.equal([ { message: 'Interface field AnotherInterface.newInterfaceField expects type NewInterface but AnotherObject.newInterfaceField is type MismatchingInterface.', @@ -1051,7 +1048,7 @@ describe('Type System: Interface fields must have output types', () => { it('rejects an empty Interface field type', () => { const schema = schemaWithInterfaceFieldOfType(undefined); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'The type of BadInterface.badField must be Output Type but got: undefined.', @@ -1062,11 +1059,9 @@ describe('Type System: Interface fields must have output types', () => { notOutputTypes.forEach(type => { it(`rejects a non-output type as an Interface field type: ${type}`, () => { const schema = schemaWithInterfaceFieldOfType(type); - expect(validateSchema(schema)).to.containSubset([ - { - message: `The type of BadInterface.badField must be Output Type but got: ${type}.`, - }, - ]); + expect(validateSchema(schema)).to.deep.include({ + message: `The type of BadInterface.badField must be Output Type but got: ${type}.`, + }); }); }); @@ -1084,7 +1079,7 @@ describe('Type System: Interface fields must have output types', () => { foo: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'The type of SomeInterface.field must be Output Type but got: SomeInputObject.', @@ -1127,7 +1122,7 @@ describe('Type System: Field arguments must have input types', () => { it('rejects an empty field arg type', () => { const schema = schemaWithArgOfType(undefined); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'The type of BadObject.badField(badArg:) must be Input Type but got: undefined.', @@ -1138,11 +1133,9 @@ describe('Type System: Field arguments must have input types', () => { notInputTypes.forEach(type => { it(`rejects a non-input type as a field arg type: ${type}`, () => { const schema = schemaWithArgOfType(type); - expect(validateSchema(schema)).to.containSubset([ - { - message: `The type of BadObject.badField(badArg:) must be Input Type but got: ${type}.`, - }, - ]); + expect(validateSchema(schema)).to.deep.include({ + message: `The type of BadObject.badField(badArg:) must be Input Type but got: ${type}.`, + }); }); }); @@ -1156,7 +1149,7 @@ describe('Type System: Field arguments must have input types', () => { foo: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'The type of Query.test(arg:) must be Input Type but got: SomeObject.', @@ -1199,7 +1192,7 @@ describe('Type System: Input Object fields must have input types', () => { it('rejects an empty input field type', () => { const schema = schemaWithInputFieldOfType(undefined); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'The type of BadInputObject.badField must be Input Type but got: undefined.', @@ -1210,11 +1203,9 @@ describe('Type System: Input Object fields must have input types', () => { notInputTypes.forEach(type => { it(`rejects a non-input type as an input field type: ${type}`, () => { const schema = schemaWithInputFieldOfType(type); - expect(validateSchema(schema)).to.containSubset([ - { - message: `The type of BadInputObject.badField must be Input Type but got: ${type}.`, - }, - ]); + expect(validateSchema(schema)).to.deep.include({ + message: `The type of BadInputObject.badField must be Input Type but got: ${type}.`, + }); }); }); @@ -1232,7 +1223,7 @@ describe('Type System: Input Object fields must have input types', () => { bar: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'The type of SomeInputObject.foo must be Input Type but got: SomeObject.', @@ -1309,7 +1300,7 @@ describe('Objects must adhere to Interface they implement', () => { anotherField: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Interface field AnotherInterface.field expected but ' + @@ -1333,7 +1324,7 @@ describe('Objects must adhere to Interface they implement', () => { field(input: String): Int } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Interface field AnotherInterface.field expects type String but ' + @@ -1360,7 +1351,7 @@ describe('Objects must adhere to Interface they implement', () => { field: B } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Interface field AnotherInterface.field expects type A but ' + @@ -1424,7 +1415,7 @@ describe('Objects must adhere to Interface they implement', () => { field: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Interface field argument AnotherInterface.field(input:) expected ' + @@ -1448,7 +1439,7 @@ describe('Objects must adhere to Interface they implement', () => { field(input: Int): String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Interface field argument AnotherInterface.field(input:) expects ' + @@ -1472,7 +1463,7 @@ describe('Objects must adhere to Interface they implement', () => { field(input: Int): Int } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Interface field AnotherInterface.field expects type String but ' + @@ -1502,7 +1493,7 @@ describe('Objects must adhere to Interface they implement', () => { field(input: String, anotherInput: String!): String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Object field argument AnotherObject.field(anotherInput:) is of ' + @@ -1544,7 +1535,7 @@ describe('Objects must adhere to Interface they implement', () => { field: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Interface field AnotherInterface.field expects type [String] ' + @@ -1568,7 +1559,7 @@ describe('Objects must adhere to Interface they implement', () => { field: [String] } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Interface field AnotherInterface.field expects type String but ' + @@ -1609,7 +1600,7 @@ describe('Objects must adhere to Interface they implement', () => { field: String } `); - expect(validateSchema(schema)).to.containSubset([ + expect(validateSchema(schema)).to.deep.equal([ { message: 'Interface field AnotherInterface.field expects type String! ' + diff --git a/src/utilities/__tests__/isValidLiteralValue-test.js b/src/utilities/__tests__/isValidLiteralValue-test.js index 21f9949e2eb..c5a15303d0c 100644 --- a/src/utilities/__tests__/isValidLiteralValue-test.js +++ b/src/utilities/__tests__/isValidLiteralValue-test.js @@ -23,7 +23,6 @@ describe('isValidLiteralValue', () => { { message: 'Expected type Int, found "abc".', locations: [{ line: 1, column: 1 }], - path: undefined, }, ]); }); diff --git a/src/validation/__tests__/ExecutableDefinitions-test.js b/src/validation/__tests__/ExecutableDefinitions-test.js index bd361e73ab9..3a626a31430 100644 --- a/src/validation/__tests__/ExecutableDefinitions-test.js +++ b/src/validation/__tests__/ExecutableDefinitions-test.js @@ -16,7 +16,6 @@ function nonExecutableDefinition(defName, line, column) { return { message: nonExecutableDefinitionMessage(defName), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/FieldsOnCorrectType-test.js b/src/validation/__tests__/FieldsOnCorrectType-test.js index 94e803d007a..9241f0d90da 100644 --- a/src/validation/__tests__/FieldsOnCorrectType-test.js +++ b/src/validation/__tests__/FieldsOnCorrectType-test.js @@ -29,7 +29,6 @@ function undefinedField( suggestedFields, ), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/FragmentsOnCompositeTypes-test.js b/src/validation/__tests__/FragmentsOnCompositeTypes-test.js index ad701cf02a7..6a6a04670af 100644 --- a/src/validation/__tests__/FragmentsOnCompositeTypes-test.js +++ b/src/validation/__tests__/FragmentsOnCompositeTypes-test.js @@ -17,7 +17,6 @@ function error(fragName, typeName, line, column) { return { message: fragmentOnNonCompositeErrorMessage(fragName, typeName), locations: [{ line, column }], - path: undefined, }; } @@ -131,7 +130,6 @@ describe('Validate: Fragments on composite types', () => { { message: inlineFragmentOnNonCompositeErrorMessage('String'), locations: [{ line: 3, column: 16 }], - path: undefined, }, ], ); diff --git a/src/validation/__tests__/KnownArgumentNames-test.js b/src/validation/__tests__/KnownArgumentNames-test.js index 7cf5d67959d..b0d155021dc 100644 --- a/src/validation/__tests__/KnownArgumentNames-test.js +++ b/src/validation/__tests__/KnownArgumentNames-test.js @@ -17,7 +17,6 @@ function unknownArg(argName, fieldName, typeName, suggestedArgs, line, column) { return { message: unknownArgMessage(argName, fieldName, typeName, suggestedArgs), locations: [{ line, column }], - path: undefined, }; } @@ -31,7 +30,6 @@ function unknownDirectiveArg( return { message: unknownDirectiveArgMessage(argName, directiveName, suggestedArgs), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/KnownDirectives-test.js b/src/validation/__tests__/KnownDirectives-test.js index dc9e66ad248..ae460296509 100644 --- a/src/validation/__tests__/KnownDirectives-test.js +++ b/src/validation/__tests__/KnownDirectives-test.js @@ -17,7 +17,6 @@ function unknownDirective(directiveName, line, column) { return { message: unknownDirectiveMessage(directiveName), locations: [{ line, column }], - path: undefined, }; } @@ -25,7 +24,6 @@ function misplacedDirective(directiveName, placement, line, column) { return { message: misplacedDirectiveMessage(directiveName, placement), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/KnownFragmentNames-test.js b/src/validation/__tests__/KnownFragmentNames-test.js index 786cc39462b..8afbe73cc9a 100644 --- a/src/validation/__tests__/KnownFragmentNames-test.js +++ b/src/validation/__tests__/KnownFragmentNames-test.js @@ -16,7 +16,6 @@ function undefFrag(fragName, line, column) { return { message: unknownFragmentMessage(fragName), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/KnownTypeNames-test.js b/src/validation/__tests__/KnownTypeNames-test.js index d18f8a97bad..70461b875d5 100644 --- a/src/validation/__tests__/KnownTypeNames-test.js +++ b/src/validation/__tests__/KnownTypeNames-test.js @@ -13,7 +13,6 @@ function unknownType(typeName, suggestedTypes, line, column) { return { message: unknownTypeMessage(typeName, suggestedTypes), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/LoneAnonymousOperation-test.js b/src/validation/__tests__/LoneAnonymousOperation-test.js index 4ec88fc31df..29917d96d74 100644 --- a/src/validation/__tests__/LoneAnonymousOperation-test.js +++ b/src/validation/__tests__/LoneAnonymousOperation-test.js @@ -16,7 +16,6 @@ function anonNotAlone(line, column) { return { message: anonOperationNotAloneMessage(), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/NoFragmentCycles-test.js b/src/validation/__tests__/NoFragmentCycles-test.js index 65dce89168e..9274029e758 100644 --- a/src/validation/__tests__/NoFragmentCycles-test.js +++ b/src/validation/__tests__/NoFragmentCycles-test.js @@ -79,7 +79,6 @@ describe('Validate: No circular fragment spreads', () => { { message: cycleErrorMessage('fragA', []), locations: [{ line: 2, column: 45 }], - path: undefined, }, ], ); @@ -95,7 +94,6 @@ describe('Validate: No circular fragment spreads', () => { { message: cycleErrorMessage('fragA', []), locations: [{ line: 2, column: 31 }], - path: undefined, }, ], ); @@ -115,7 +113,6 @@ describe('Validate: No circular fragment spreads', () => { { message: cycleErrorMessage('fragA', []), locations: [{ line: 4, column: 11 }], - path: undefined, }, ], ); @@ -132,7 +129,6 @@ describe('Validate: No circular fragment spreads', () => { { message: cycleErrorMessage('fragA', ['fragB']), locations: [{ line: 2, column: 31 }, { line: 3, column: 31 }], - path: undefined, }, ], ); @@ -149,7 +145,6 @@ describe('Validate: No circular fragment spreads', () => { { message: cycleErrorMessage('fragB', ['fragA']), locations: [{ line: 2, column: 31 }, { line: 3, column: 31 }], - path: undefined, }, ], ); @@ -174,7 +169,6 @@ describe('Validate: No circular fragment spreads', () => { { message: cycleErrorMessage('fragA', ['fragB']), locations: [{ line: 4, column: 11 }, { line: 9, column: 11 }], - path: undefined, }, ], ); @@ -208,7 +202,6 @@ describe('Validate: No circular fragment spreads', () => { { line: 8, column: 31 }, { line: 9, column: 31 }, ], - path: undefined, }, { message: cycleErrorMessage('fragO', [ @@ -224,7 +217,6 @@ describe('Validate: No circular fragment spreads', () => { { line: 6, column: 31 }, { line: 7, column: 31 }, ], - path: undefined, }, ], ); @@ -242,12 +234,10 @@ describe('Validate: No circular fragment spreads', () => { { message: cycleErrorMessage('fragA', ['fragB']), locations: [{ line: 2, column: 31 }, { line: 3, column: 31 }], - path: undefined, }, { message: cycleErrorMessage('fragA', ['fragC']), locations: [{ line: 2, column: 41 }, { line: 4, column: 31 }], - path: undefined, }, ], ); @@ -265,12 +255,10 @@ describe('Validate: No circular fragment spreads', () => { { message: cycleErrorMessage('fragA', ['fragC']), locations: [{ line: 2, column: 31 }, { line: 4, column: 31 }], - path: undefined, }, { message: cycleErrorMessage('fragC', ['fragB']), locations: [{ line: 4, column: 41 }, { line: 3, column: 31 }], - path: undefined, }, ], ); @@ -288,7 +276,6 @@ describe('Validate: No circular fragment spreads', () => { { message: cycleErrorMessage('fragB', []), locations: [{ line: 3, column: 31 }], - path: undefined, }, { message: cycleErrorMessage('fragA', ['fragB', 'fragC']), @@ -297,12 +284,10 @@ describe('Validate: No circular fragment spreads', () => { { line: 3, column: 41 }, { line: 4, column: 31 }, ], - path: undefined, }, { message: cycleErrorMessage('fragB', ['fragC']), locations: [{ line: 3, column: 41 }, { line: 4, column: 41 }], - path: undefined, }, ], ); diff --git a/src/validation/__tests__/NoUndefinedVariables-test.js b/src/validation/__tests__/NoUndefinedVariables-test.js index 99f8cf837a6..ff7e096ca10 100644 --- a/src/validation/__tests__/NoUndefinedVariables-test.js +++ b/src/validation/__tests__/NoUndefinedVariables-test.js @@ -16,7 +16,6 @@ function undefVar(varName, l1, c1, opName, l2, c2) { return { message: undefinedVarMessage(varName, opName), locations: [{ line: l1, column: c1 }, { line: l2, column: c2 }], - path: undefined, }; } diff --git a/src/validation/__tests__/NoUnusedFragments-test.js b/src/validation/__tests__/NoUnusedFragments-test.js index 3a1f50926b8..fa68ce0ab92 100644 --- a/src/validation/__tests__/NoUnusedFragments-test.js +++ b/src/validation/__tests__/NoUnusedFragments-test.js @@ -16,7 +16,6 @@ function unusedFrag(fragName, line, column) { return { message: unusedFragMessage(fragName), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/NoUnusedVariables-test.js b/src/validation/__tests__/NoUnusedVariables-test.js index 604f84e62a6..fabe5844dea 100644 --- a/src/validation/__tests__/NoUnusedVariables-test.js +++ b/src/validation/__tests__/NoUnusedVariables-test.js @@ -16,7 +16,6 @@ function unusedVar(varName, opName, line, column) { return { message: unusedVariableMessage(varName, opName), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js b/src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js index 97da5c5ccb9..97d66b9ff29 100644 --- a/src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js +++ b/src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js @@ -132,7 +132,6 @@ describe('Validate: Overlapping fields can be merged', () => { 'name and nickname are different fields', ), locations: [{ line: 3, column: 9 }, { line: 4, column: 9 }], - path: undefined, }, ], ); @@ -172,7 +171,6 @@ describe('Validate: Overlapping fields can be merged', () => { 'nickname and name are different fields', ), locations: [{ line: 3, column: 9 }, { line: 4, column: 9 }], - path: undefined, }, ], ); @@ -194,7 +192,6 @@ describe('Validate: Overlapping fields can be merged', () => { 'they have differing arguments', ), locations: [{ line: 3, column: 9 }, { line: 4, column: 9 }], - path: undefined, }, ], ); @@ -216,7 +213,6 @@ describe('Validate: Overlapping fields can be merged', () => { 'they have differing arguments', ), locations: [{ line: 3, column: 9 }, { line: 4, column: 9 }], - path: undefined, }, ], ); @@ -238,7 +234,6 @@ describe('Validate: Overlapping fields can be merged', () => { 'they have differing arguments', ), locations: [{ line: 3, column: 9 }, { line: 4, column: 9 }], - path: undefined, }, ], ); @@ -281,7 +276,6 @@ describe('Validate: Overlapping fields can be merged', () => { { message: fieldsConflictMessage('x', 'a and b are different fields'), locations: [{ line: 7, column: 9 }, { line: 10, column: 9 }], - path: undefined, }, ], ); @@ -317,17 +311,14 @@ describe('Validate: Overlapping fields can be merged', () => { { message: fieldsConflictMessage('x', 'a and b are different fields'), locations: [{ line: 18, column: 9 }, { line: 21, column: 9 }], - path: undefined, }, { message: fieldsConflictMessage('x', 'c and a are different fields'), locations: [{ line: 14, column: 11 }, { line: 18, column: 9 }], - path: undefined, }, { message: fieldsConflictMessage('x', 'c and b are different fields'), locations: [{ line: 14, column: 11 }, { line: 21, column: 9 }], - path: undefined, }, ], ); @@ -357,7 +348,6 @@ describe('Validate: Overlapping fields can be merged', () => { { line: 6, column: 9 }, { line: 7, column: 11 }, ], - path: undefined, }, ], ); @@ -392,7 +382,6 @@ describe('Validate: Overlapping fields can be merged', () => { { line: 8, column: 11 }, { line: 9, column: 11 }, ], - path: undefined, }, ], ); @@ -428,7 +417,6 @@ describe('Validate: Overlapping fields can be merged', () => { { line: 9, column: 11 }, { line: 10, column: 13 }, ], - path: undefined, }, ], ); @@ -465,7 +453,6 @@ describe('Validate: Overlapping fields can be merged', () => { { line: 7, column: 11 }, { line: 8, column: 13 }, ], - path: undefined, }, ], ); @@ -510,7 +497,6 @@ describe('Validate: Overlapping fields can be merged', () => { { line: 15, column: 11 }, { line: 16, column: 13 }, ], - path: undefined, }, ], ); @@ -557,7 +543,6 @@ describe('Validate: Overlapping fields can be merged', () => { { line: 22, column: 9 }, { line: 18, column: 9 }, ], - path: undefined, }, ], ); @@ -712,7 +697,6 @@ describe('Validate: Overlapping fields can be merged', () => { 'they return conflicting types Int and String!', ), locations: [{ line: 5, column: 15 }, { line: 8, column: 15 }], - path: undefined, }, ], ); @@ -767,7 +751,6 @@ describe('Validate: Overlapping fields can be merged', () => { 'they return conflicting types Int and String', ), locations: [{ line: 5, column: 15 }, { line: 8, column: 15 }], - path: undefined, }, ], ); @@ -832,7 +815,6 @@ describe('Validate: Overlapping fields can be merged', () => { { line: 34, column: 11 }, { line: 42, column: 11 }, ], - path: undefined, }, ], ); @@ -861,7 +843,6 @@ describe('Validate: Overlapping fields can be merged', () => { 'they return conflicting types String! and String', ), locations: [{ line: 5, column: 15 }, { line: 8, column: 15 }], - path: undefined, }, ], ); @@ -894,7 +875,6 @@ describe('Validate: Overlapping fields can be merged', () => { 'they return conflicting types [StringBox] and StringBox', ), locations: [{ line: 5, column: 15 }, { line: 10, column: 15 }], - path: undefined, }, ], ); @@ -925,7 +905,6 @@ describe('Validate: Overlapping fields can be merged', () => { 'they return conflicting types StringBox and [StringBox]', ), locations: [{ line: 5, column: 15 }, { line: 10, column: 15 }], - path: undefined, }, ], ); @@ -959,7 +938,6 @@ describe('Validate: Overlapping fields can be merged', () => { 'scalar and unrelatedField are different fields', ), locations: [{ line: 6, column: 17 }, { line: 7, column: 17 }], - path: undefined, }, ], ); @@ -996,7 +974,6 @@ describe('Validate: Overlapping fields can be merged', () => { { line: 10, column: 15 }, { line: 11, column: 17 }, ], - path: undefined, }, ], ); @@ -1092,7 +1069,6 @@ describe('Validate: Overlapping fields can be merged', () => { { line: 15, column: 13 }, { line: 16, column: 15 }, ], - path: undefined, }, ], ); @@ -1204,7 +1180,6 @@ describe('Validate: Overlapping fields can be merged', () => { 'name and nickname are different fields', ), locations: [{ line: 4, column: 9 }, { line: 5, column: 9 }], - path: undefined, }, ], ); diff --git a/src/validation/__tests__/PossibleFragmentSpreads-test.js b/src/validation/__tests__/PossibleFragmentSpreads-test.js index 7022f142667..945ce6a23b0 100644 --- a/src/validation/__tests__/PossibleFragmentSpreads-test.js +++ b/src/validation/__tests__/PossibleFragmentSpreads-test.js @@ -17,7 +17,6 @@ function error(fragName, parentType, fragType, line, column) { return { message: typeIncompatibleSpreadMessage(fragName, parentType, fragType), locations: [{ line, column }], - path: undefined, }; } @@ -25,7 +24,6 @@ function errorAnon(parentType, fragType, line, column) { return { message: typeIncompatibleAnonSpreadMessage(parentType, fragType), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/ProvidedNonNullArguments-test.js b/src/validation/__tests__/ProvidedNonNullArguments-test.js index a6779f70c95..42b645e4412 100644 --- a/src/validation/__tests__/ProvidedNonNullArguments-test.js +++ b/src/validation/__tests__/ProvidedNonNullArguments-test.js @@ -17,7 +17,6 @@ function missingFieldArg(fieldName, argName, typeName, line, column) { return { message: missingFieldArgMessage(fieldName, argName, typeName), locations: [{ line, column }], - path: undefined, }; } @@ -25,7 +24,6 @@ function missingDirectiveArg(directiveName, argName, typeName, line, column) { return { message: missingDirectiveArgMessage(directiveName, argName, typeName), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/ScalarLeafs-test.js b/src/validation/__tests__/ScalarLeafs-test.js index d75b0a5fa62..c541313bdef 100644 --- a/src/validation/__tests__/ScalarLeafs-test.js +++ b/src/validation/__tests__/ScalarLeafs-test.js @@ -17,7 +17,6 @@ function noScalarSubselection(field, type, line, column) { return { message: noSubselectionAllowedMessage(field, type), locations: [{ line, column }], - path: undefined, }; } @@ -25,7 +24,6 @@ function missingObjSubselection(field, type, line, column) { return { message: requiredSubselectionMessage(field, type), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/SingleFieldSubscriptions-test.js b/src/validation/__tests__/SingleFieldSubscriptions-test.js index 9fc23a0d9e9..0827ca89673 100644 --- a/src/validation/__tests__/SingleFieldSubscriptions-test.js +++ b/src/validation/__tests__/SingleFieldSubscriptions-test.js @@ -37,7 +37,6 @@ describe('Validate: Subscriptions with single field', () => { { message: singleFieldOnlyMessage('ImportantEmails'), locations: [{ line: 4, column: 9 }], - path: undefined, }, ], ); @@ -56,7 +55,6 @@ describe('Validate: Subscriptions with single field', () => { { message: singleFieldOnlyMessage('ImportantEmails'), locations: [{ line: 4, column: 9 }], - path: undefined, }, ], ); @@ -76,7 +74,6 @@ describe('Validate: Subscriptions with single field', () => { { message: singleFieldOnlyMessage('ImportantEmails'), locations: [{ line: 4, column: 9 }, { line: 5, column: 9 }], - path: undefined, }, ], ); @@ -95,7 +92,6 @@ describe('Validate: Subscriptions with single field', () => { { message: singleFieldOnlyMessage(null), locations: [{ line: 4, column: 9 }], - path: undefined, }, ], ); diff --git a/src/validation/__tests__/UniqueArgumentNames-test.js b/src/validation/__tests__/UniqueArgumentNames-test.js index c54a647e9b7..2dade3875fe 100644 --- a/src/validation/__tests__/UniqueArgumentNames-test.js +++ b/src/validation/__tests__/UniqueArgumentNames-test.js @@ -16,7 +16,6 @@ function duplicateArg(argName, l1, c1, l2, c2) { return { message: duplicateArgMessage(argName), locations: [{ line: l1, column: c1 }, { line: l2, column: c2 }], - path: undefined, }; } diff --git a/src/validation/__tests__/UniqueDirectivesPerLocation-test.js b/src/validation/__tests__/UniqueDirectivesPerLocation-test.js index d4e86fbcf7c..c423e906fea 100644 --- a/src/validation/__tests__/UniqueDirectivesPerLocation-test.js +++ b/src/validation/__tests__/UniqueDirectivesPerLocation-test.js @@ -16,7 +16,6 @@ function duplicateDirective(directiveName, l1, c1, l2, c2) { return { message: duplicateDirectiveMessage(directiveName), locations: [{ line: l1, column: c1 }, { line: l2, column: c2 }], - path: undefined, }; } diff --git a/src/validation/__tests__/UniqueFragmentNames-test.js b/src/validation/__tests__/UniqueFragmentNames-test.js index c62e61b6260..117b6db2618 100644 --- a/src/validation/__tests__/UniqueFragmentNames-test.js +++ b/src/validation/__tests__/UniqueFragmentNames-test.js @@ -16,7 +16,6 @@ function duplicateFrag(fragName, l1, c1, l2, c2) { return { message: duplicateFragmentNameMessage(fragName), locations: [{ line: l1, column: c1 }, { line: l2, column: c2 }], - path: undefined, }; } diff --git a/src/validation/__tests__/UniqueInputFieldNames-test.js b/src/validation/__tests__/UniqueInputFieldNames-test.js index b5dcdbc20ae..0b804dbe656 100644 --- a/src/validation/__tests__/UniqueInputFieldNames-test.js +++ b/src/validation/__tests__/UniqueInputFieldNames-test.js @@ -16,7 +16,6 @@ function duplicateField(name, l1, c1, l2, c2) { return { message: duplicateInputFieldMessage(name), locations: [{ line: l1, column: c1 }, { line: l2, column: c2 }], - path: undefined, }; } diff --git a/src/validation/__tests__/UniqueOperationNames-test.js b/src/validation/__tests__/UniqueOperationNames-test.js index cd29e900b37..f6dc9aa61f5 100644 --- a/src/validation/__tests__/UniqueOperationNames-test.js +++ b/src/validation/__tests__/UniqueOperationNames-test.js @@ -16,7 +16,6 @@ function duplicateOp(opName, l1, c1, l2, c2) { return { message: duplicateOperationNameMessage(opName), locations: [{ line: l1, column: c1 }, { line: l2, column: c2 }], - path: undefined, }; } diff --git a/src/validation/__tests__/UniqueVariableNames-test.js b/src/validation/__tests__/UniqueVariableNames-test.js index 9356710f983..deae3635c90 100644 --- a/src/validation/__tests__/UniqueVariableNames-test.js +++ b/src/validation/__tests__/UniqueVariableNames-test.js @@ -16,7 +16,6 @@ function duplicateVariable(name, l1, c1, l2, c2) { return { message: duplicateVariableMessage(name), locations: [{ line: l1, column: c1 }, { line: l2, column: c2 }], - path: undefined, }; } diff --git a/src/validation/__tests__/ValuesOfCorrectType-test.js b/src/validation/__tests__/ValuesOfCorrectType-test.js index ba2ed1b04da..8237675a3b8 100644 --- a/src/validation/__tests__/ValuesOfCorrectType-test.js +++ b/src/validation/__tests__/ValuesOfCorrectType-test.js @@ -19,7 +19,6 @@ function badValue(typeName, value, line, column, message) { return { message: badValueMessage(typeName, value, message), locations: [{ line, column }], - path: undefined, }; } @@ -27,7 +26,6 @@ function requiredField(typeName, fieldName, fieldTypeName, line, column) { return { message: requiredFieldMessage(typeName, fieldName, fieldTypeName), locations: [{ line, column }], - path: undefined, }; } @@ -35,7 +33,6 @@ function unknownField(typeName, fieldName, line, column, message) { return { message: unknownFieldMessage(typeName, fieldName, message), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/VariablesAreInputTypes-test.js b/src/validation/__tests__/VariablesAreInputTypes-test.js index c2e22e68855..25e4a2bd8be 100644 --- a/src/validation/__tests__/VariablesAreInputTypes-test.js +++ b/src/validation/__tests__/VariablesAreInputTypes-test.js @@ -36,17 +36,14 @@ describe('Validate: Variables are input types', () => { { locations: [{ line: 2, column: 21 }], message: nonInputTypeOnVarMessage('a', 'Dog'), - path: undefined, }, { locations: [{ line: 2, column: 30 }], message: nonInputTypeOnVarMessage('b', '[[CatOrDog!]]!'), - path: undefined, }, { locations: [{ line: 2, column: 50 }], message: nonInputTypeOnVarMessage('c', 'Pet'), - path: undefined, }, ], ); diff --git a/src/validation/__tests__/VariablesDefaultValueAllowed-test.js b/src/validation/__tests__/VariablesDefaultValueAllowed-test.js index 12c084d9836..26707d0b366 100644 --- a/src/validation/__tests__/VariablesDefaultValueAllowed-test.js +++ b/src/validation/__tests__/VariablesDefaultValueAllowed-test.js @@ -16,7 +16,6 @@ function defaultForRequiredVar(varName, typeName, guessTypeName, line, column) { return { message: defaultForRequiredVarMessage(varName, typeName, guessTypeName), locations: [{ line, column }], - path: undefined, }; } diff --git a/src/validation/__tests__/VariablesInAllowedPosition-test.js b/src/validation/__tests__/VariablesInAllowedPosition-test.js index 94afbedf94c..d522e5b6a22 100644 --- a/src/validation/__tests__/VariablesInAllowedPosition-test.js +++ b/src/validation/__tests__/VariablesInAllowedPosition-test.js @@ -227,7 +227,6 @@ describe('Validate: Variables are in allowed positions', () => { { message: badVarPosMessage('intArg', 'Int', 'Int!'), locations: [{ line: 2, column: 19 }, { line: 4, column: 45 }], - path: undefined, }, ], ); @@ -251,7 +250,6 @@ describe('Validate: Variables are in allowed positions', () => { { message: badVarPosMessage('intArg', 'Int', 'Int!'), locations: [{ line: 6, column: 19 }, { line: 3, column: 43 }], - path: undefined, }, ], ); @@ -279,7 +277,6 @@ describe('Validate: Variables are in allowed positions', () => { { message: badVarPosMessage('intArg', 'Int', 'Int!'), locations: [{ line: 10, column: 19 }, { line: 7, column: 43 }], - path: undefined, }, ], ); @@ -299,7 +296,6 @@ describe('Validate: Variables are in allowed positions', () => { { message: badVarPosMessage('stringVar', 'String', 'Boolean'), locations: [{ line: 2, column: 19 }, { line: 4, column: 39 }], - path: undefined, }, ], ); @@ -319,7 +315,6 @@ describe('Validate: Variables are in allowed positions', () => { { message: badVarPosMessage('stringVar', 'String', '[String]'), locations: [{ line: 2, column: 19 }, { line: 4, column: 45 }], - path: undefined, }, ], ); @@ -337,7 +332,6 @@ describe('Validate: Variables are in allowed positions', () => { { message: badVarPosMessage('boolVar', 'Boolean', 'Boolean!'), locations: [{ line: 2, column: 19 }, { line: 3, column: 26 }], - path: undefined, }, ], ); @@ -355,7 +349,6 @@ describe('Validate: Variables are in allowed positions', () => { { message: badVarPosMessage('stringVar', 'String', 'Boolean!'), locations: [{ line: 2, column: 19 }, { line: 3, column: 26 }], - path: undefined, }, ], ); @@ -376,7 +369,6 @@ describe('Validate: Variables are in allowed positions', () => { { message: badVarPosMessage('stringListVar', '[String]', '[String!]'), locations: [{ line: 2, column: 19 }, { line: 5, column: 59 }], - path: undefined, }, ], ); diff --git a/src/validation/__tests__/harness.js b/src/validation/__tests__/harness.js index d8c37fc7c41..7efefb89234 100644 --- a/src/validation/__tests__/harness.js +++ b/src/validation/__tests__/harness.js @@ -7,7 +7,6 @@ import { expect } from 'chai'; import { parse } from '../../language'; -import { formatError } from '../../error'; import { validate } from '../validate'; import { GraphQLSchema, @@ -423,7 +422,7 @@ function expectValid(schema, rules, queryString) { function expectInvalid(schema, rules, queryString, expectedErrors) { const errors = validate(schema, parse(queryString), rules); expect(errors).to.have.length.of.at.least(1, 'Should not validate'); - expect(errors.map(formatError)).to.deep.equal(expectedErrors); + expect(errors).to.deep.equal(expectedErrors); return errors; } diff --git a/src/validation/__tests__/validation-test.js b/src/validation/__tests__/validation-test.js index 6876d31ac52..56881dc8432 100644 --- a/src/validation/__tests__/validation-test.js +++ b/src/validation/__tests__/validation-test.js @@ -50,7 +50,6 @@ describe('Validate: Supports full validation', () => { message: 'Expected type Invalid, found "bad value"; ' + 'Invalid scalar is always invalid: bad value', - path: undefined, }, ]); });