diff --git a/src/execution/__tests__/abstract-promise-test.js b/src/execution/__tests__/abstract-promise-test.js index 5080a92a0e..209a946589 100644 --- a/src/execution/__tests__/abstract-promise-test.js +++ b/src/execution/__tests__/abstract-promise-test.js @@ -86,17 +86,19 @@ describe('Execute: Handles execution of abstract types with promises', () => { types: [CatType, DogType], }); - const query = `{ - pets { - name - ... on Dog { - woofs - } - ... on Cat { - meows + const query = ` + { + pets { + name + ... on Dog { + woofs + } + ... on Cat { + meows + } } } - }`; + `; const result = await graphql(schema, query); @@ -159,17 +161,19 @@ describe('Execute: Handles execution of abstract types with promises', () => { types: [CatType, DogType], }); - const query = `{ - pets { - name - ... on Dog { - woofs - } - ... on Cat { - meows + const query = ` + { + pets { + name + ... on Dog { + woofs + } + ... on Cat { + meows + } } } - }`; + `; const result = await graphql(schema, query); @@ -180,12 +184,12 @@ describe('Execute: Handles execution of abstract types with promises', () => { errors: [ { message: 'We are testing this error', - locations: [{ line: 2, column: 7 }], + locations: [{ line: 3, column: 9 }], path: ['pets', 0], }, { message: 'We are testing this error', - locations: [{ line: 2, column: 7 }], + locations: [{ line: 3, column: 9 }], path: ['pets', 1], }, ], @@ -230,18 +234,20 @@ describe('Execute: Handles execution of abstract types with promises', () => { }), }); - const query = `{ - pets { - ... on Dog { - name - woofs - } - ... on Cat { - name - meows + const query = ` + { + pets { + ... on Dog { + name + woofs + } + ... on Cat { + name + meows + } } } - }`; + `; const result = await graphql(schema, query); @@ -324,17 +330,19 @@ describe('Execute: Handles execution of abstract types with promises', () => { types: [CatType, DogType], }); - const query = `{ - pets { - name - ... on Dog { - woofs - } - ... on Cat { - meows + const query = ` + { + pets { + name + ... on Dog { + woofs + } + ... on Cat { + meows + } } } - }`; + `; const result = await graphql(schema, query); @@ -356,7 +364,7 @@ describe('Execute: Handles execution of abstract types with promises', () => { { message: 'Runtime Object type "Human" is not a possible type for "Pet".', - locations: [{ line: 2, column: 7 }], + locations: [{ line: 3, column: 9 }], path: ['pets', 2], }, ], @@ -421,18 +429,20 @@ describe('Execute: Handles execution of abstract types with promises', () => { }), }); - const query = `{ - pets { - ... on Dog { - name - woofs - } - ... on Cat { - name - meows + const query = ` + { + pets { + ... on Dog { + name + woofs + } + ... on Cat { + name + meows + } } } - }`; + `; const result = await graphql(schema, query); @@ -454,7 +464,7 @@ describe('Execute: Handles execution of abstract types with promises', () => { { message: 'Runtime Object type "Human" is not a possible type for "Pet".', - locations: [{ line: 2, column: 7 }], + locations: [{ line: 3, column: 9 }], path: ['pets', 2], }, ], @@ -507,17 +517,19 @@ describe('Execute: Handles execution of abstract types with promises', () => { types: [CatType, DogType], }); - const query = `{ - pets { - name - ... on Dog { - woofs - } - ... on Cat { - meows + const query = ` + { + pets { + name + ... on Dog { + woofs + } + ... on Cat { + meows + } } } - }`; + `; const result = await graphql(schema, query); @@ -579,17 +591,19 @@ describe('Execute: Handles execution of abstract types with promises', () => { types: [CatType, DogType], }); - const query = `{ - pets { - name - ... on Dog { - woofs - } - ... on Cat { - meows + const query = ` + { + pets { + name + ... on Dog { + woofs + } + ... on Cat { + meows + } } } - }`; + `; const result = await graphql(schema, query); @@ -600,12 +614,12 @@ describe('Execute: Handles execution of abstract types with promises', () => { errors: [ { message: 'We are testing this error', - locations: [{ line: 2, column: 7 }], + locations: [{ line: 3, column: 9 }], path: ['pets', 0], }, { message: 'We are testing this error', - locations: [{ line: 2, column: 7 }], + locations: [{ line: 3, column: 9 }], path: ['pets', 1], }, ], diff --git a/src/execution/__tests__/abstract-test.js b/src/execution/__tests__/abstract-test.js index be4159e79a..b501b0e1d4 100644 --- a/src/execution/__tests__/abstract-test.js +++ b/src/execution/__tests__/abstract-test.js @@ -86,17 +86,19 @@ describe('Execute: Handles execution of abstract types', () => { types: [CatType, DogType], }); - const query = `{ - pets { - name - ... on Dog { - woofs - } - ... on Cat { - meows + const query = ` + { + pets { + name + ... on Dog { + woofs + } + ... on Cat { + meows + } } } - }`; + `; const result = graphqlSync(schema, query); @@ -246,17 +248,19 @@ describe('Execute: Handles execution of abstract types', () => { types: [CatType, DogType], }); - const query = `{ - pets { - name - ... on Dog { - woofs - } - ... on Cat { - meows + const query = ` + { + pets { + name + ... on Dog { + woofs + } + ... on Cat { + meows + } } } - }`; + `; const result = graphqlSync(schema, query); @@ -278,7 +282,7 @@ describe('Execute: Handles execution of abstract types', () => { { message: 'Runtime Object type "Human" is not a possible type for "Pet".', - locations: [{ line: 2, column: 7 }], + locations: [{ line: 3, column: 9 }], path: ['pets', 2], }, ], @@ -341,18 +345,20 @@ describe('Execute: Handles execution of abstract types', () => { }), }); - const query = `{ - pets { - ... on Dog { - name - woofs - } - ... on Cat { - name - meows + const query = ` + { + pets { + ... on Dog { + name + woofs + } + ... on Cat { + name + meows + } } } - }`; + `; const result = graphqlSync(schema, query); @@ -374,7 +380,7 @@ describe('Execute: Handles execution of abstract types', () => { { message: 'Runtime Object type "Human" is not a possible type for "Pet".', - locations: [{ line: 2, column: 7 }], + locations: [{ line: 3, column: 9 }], path: ['pets', 2], }, ], @@ -469,17 +475,19 @@ describe('Execute: Handles execution of abstract types', () => { types: [CatType, DogType], }); - const query = `{ - pets { - name - ... on Dog { - woofs - } - ... on Cat { - meows + const query = ` + { + pets { + name + ... on Dog { + woofs + } + ... on Cat { + meows + } } } - }`; + `; const result = graphqlSync(schema, query); diff --git a/src/execution/__tests__/mutations-test.js b/src/execution/__tests__/mutations-test.js index 07f3c4ae00..451770ee8d 100644 --- a/src/execution/__tests__/mutations-test.js +++ b/src/execution/__tests__/mutations-test.js @@ -102,23 +102,25 @@ const schema = new GraphQLSchema({ describe('Execute: Handles mutation execution ordering', () => { it('evaluates mutations serially', async () => { - const doc = `mutation M { - first: immediatelyChangeTheNumber(newNumber: 1) { - theNumber - }, - second: promiseToChangeTheNumber(newNumber: 2) { - theNumber - }, - third: immediatelyChangeTheNumber(newNumber: 3) { - theNumber - } - fourth: promiseToChangeTheNumber(newNumber: 4) { - theNumber - }, - fifth: immediatelyChangeTheNumber(newNumber: 5) { - theNumber + const doc = ` + mutation M { + first: immediatelyChangeTheNumber(newNumber: 1) { + theNumber + }, + second: promiseToChangeTheNumber(newNumber: 2) { + theNumber + }, + third: immediatelyChangeTheNumber(newNumber: 3) { + theNumber + } + fourth: promiseToChangeTheNumber(newNumber: 4) { + theNumber + }, + fifth: immediatelyChangeTheNumber(newNumber: 5) { + theNumber + } } - }`; + `; const mutationResult = await execute(schema, parse(doc), new Root(6)); @@ -134,26 +136,28 @@ describe('Execute: Handles mutation execution ordering', () => { }); it('evaluates mutations correctly in the presence of a failed mutation', async () => { - const doc = `mutation M { - first: immediatelyChangeTheNumber(newNumber: 1) { - theNumber - }, - second: promiseToChangeTheNumber(newNumber: 2) { - theNumber - }, - third: failToChangeTheNumber(newNumber: 3) { - theNumber - } - fourth: promiseToChangeTheNumber(newNumber: 4) { - theNumber - }, - fifth: immediatelyChangeTheNumber(newNumber: 5) { - theNumber - } - sixth: promiseAndFailToChangeTheNumber(newNumber: 6) { - theNumber + const doc = ` + mutation M { + first: immediatelyChangeTheNumber(newNumber: 1) { + theNumber + }, + second: promiseToChangeTheNumber(newNumber: 2) { + theNumber + }, + third: failToChangeTheNumber(newNumber: 3) { + theNumber + } + fourth: promiseToChangeTheNumber(newNumber: 4) { + theNumber + }, + fifth: immediatelyChangeTheNumber(newNumber: 5) { + theNumber + } + sixth: promiseAndFailToChangeTheNumber(newNumber: 6) { + theNumber + } } - }`; + `; const result = await execute(schema, parse(doc), new Root(6)); @@ -169,12 +173,12 @@ describe('Execute: Handles mutation execution ordering', () => { errors: [ { message: 'Cannot change the number', - locations: [{ line: 8, column: 7 }], + locations: [{ line: 9, column: 9 }], path: ['third'], }, { message: 'Cannot change the number', - locations: [{ line: 17, column: 7 }], + locations: [{ line: 18, column: 9 }], path: ['sixth'], }, ], diff --git a/src/execution/__tests__/variables-test.js b/src/execution/__tests__/variables-test.js index 542a0ae9c2..6ec5d6c81a 100644 --- a/src/execution/__tests__/variables-test.js +++ b/src/execution/__tests__/variables-test.js @@ -295,9 +295,11 @@ describe('Execute: Handles inputs', () => { it('does not use default value when provided', () => { const result = executeQuery( - `query q($input: String = "Default value") { - fieldWithNullableStringInput(input: $input) - }`, + ` + query q($input: String = "Default value") { + fieldWithNullableStringInput(input: $input) + } + `, { input: 'Variable value' }, );