From 124090c77cd31678402048e3c5c9cf391de9697a Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Mon, 15 Mar 2021 18:47:02 +0200 Subject: [PATCH] tests: Swith to using named args for graphql/graphqlSync --- src/__tests__/starWarsConnectionTests.js | 22 ++++---- src/__tests__/starWarsMutationTests.js | 32 ++++++----- .../starWarsObjectIdentificationTests.js | 37 +++++------- src/connection/__tests__/connection.js | 30 +++------- src/mutation/__tests__/mutation.js | 45 +++++++-------- src/node/__tests__/global.js | 8 +-- src/node/__tests__/node.js | 56 +++++++++---------- src/node/__tests__/nodeasync.js | 17 ++---- src/node/__tests__/plural.js | 11 ++-- 9 files changed, 116 insertions(+), 142 deletions(-) diff --git a/src/__tests__/starWarsConnectionTests.js b/src/__tests__/starWarsConnectionTests.js index 89e16ca..848f4ba 100644 --- a/src/__tests__/starWarsConnectionTests.js +++ b/src/__tests__/starWarsConnectionTests.js @@ -2,11 +2,11 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import { graphqlSync } from 'graphql'; -import { StarWarsSchema } from './starWarsSchema'; +import { StarWarsSchema as schema } from './starWarsSchema'; describe('Star Wars connections', () => { it('fetches the first ship of the rebels', () => { - const query = ` + const source = ` query RebelsShipsQuery { rebels { name, @@ -21,7 +21,7 @@ describe('Star Wars connections', () => { } `; - expect(graphqlSync(StarWarsSchema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { rebels: { name: 'Alliance to Restore the Republic', @@ -38,7 +38,7 @@ describe('Star Wars connections', () => { }); it('fetches the first two ships of the rebels with a cursor', () => { - const query = ` + const source = ` query MoreRebelShipsQuery { rebels { name, @@ -54,7 +54,7 @@ describe('Star Wars connections', () => { } `; - expect(graphqlSync(StarWarsSchema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { rebels: { name: 'Alliance to Restore the Republic', @@ -76,7 +76,7 @@ describe('Star Wars connections', () => { }); it('fetches the next three ships of the rebels with a cursor', () => { - const query = ` + const source = ` query EndOfRebelShipsQuery { rebels { name, @@ -92,7 +92,7 @@ describe('Star Wars connections', () => { } `; - expect(graphqlSync(StarWarsSchema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { rebels: { name: 'Alliance to Restore the Republic', @@ -118,7 +118,7 @@ describe('Star Wars connections', () => { }); it('fetches no ships of the rebels at the end of connection', () => { - const query = ` + const source = ` query RebelsQuery { rebels { name, @@ -134,7 +134,7 @@ describe('Star Wars connections', () => { } `; - expect(graphqlSync(StarWarsSchema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { rebels: { name: 'Alliance to Restore the Republic', @@ -147,7 +147,7 @@ describe('Star Wars connections', () => { }); it('identifies the end of the list', () => { - const query = ` + const source = ` query EndOfRebelShipsQuery { rebels { name, @@ -175,7 +175,7 @@ describe('Star Wars connections', () => { } `; - expect(graphqlSync(StarWarsSchema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { rebels: { name: 'Alliance to Restore the Republic', diff --git a/src/__tests__/starWarsMutationTests.js b/src/__tests__/starWarsMutationTests.js index b435109..1574e2a 100644 --- a/src/__tests__/starWarsMutationTests.js +++ b/src/__tests__/starWarsMutationTests.js @@ -2,11 +2,11 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import { graphqlSync } from 'graphql'; -import { StarWarsSchema } from './starWarsSchema'; +import { StarWarsSchema as schema } from './starWarsSchema'; describe('Star Wars mutations', () => { it('mutates the data set', () => { - const mutation = ` + const source = ` mutation AddBWingQuery($input: IntroduceShipInput!) { introduceShip(input: $input) { ship { @@ -20,26 +20,28 @@ describe('Star Wars mutations', () => { } } `; - const params = { + const variableValues = { input: { shipName: 'B-Wing', factionId: '1', clientMutationId: 'abcde', }, }; - const expected = { - introduceShip: { - ship: { - id: 'U2hpcDo5', - name: 'B-Wing', - }, - faction: { - name: 'Alliance to Restore the Republic', + + const result = graphqlSync({ schema, source, variableValues }); + expect(result).to.deep.equal({ + data: { + introduceShip: { + ship: { + id: 'U2hpcDo5', + name: 'B-Wing', + }, + faction: { + name: 'Alliance to Restore the Republic', + }, + clientMutationId: 'abcde', }, - clientMutationId: 'abcde', }, - }; - const result = graphqlSync(StarWarsSchema, mutation, null, null, params); - expect(result).to.deep.equal({ data: expected }); + }); }); }); diff --git a/src/__tests__/starWarsObjectIdentificationTests.js b/src/__tests__/starWarsObjectIdentificationTests.js index b023ae5..b5a8107 100644 --- a/src/__tests__/starWarsObjectIdentificationTests.js +++ b/src/__tests__/starWarsObjectIdentificationTests.js @@ -2,11 +2,11 @@ import { expect } from 'chai'; import { describe, it } from 'mocha'; import { graphqlSync } from 'graphql'; -import { StarWarsSchema } from './starWarsSchema'; +import { StarWarsSchema as schema } from './starWarsSchema'; describe('Star Wars object identification', () => { it('fetches the ID and name of the rebels', () => { - const query = ` + const source = ` query RebelsQuery { rebels { id @@ -15,7 +15,7 @@ describe('Star Wars object identification', () => { } `; - expect(graphqlSync(StarWarsSchema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { rebels: { id: 'RmFjdGlvbjox', @@ -26,7 +26,7 @@ describe('Star Wars object identification', () => { }); it('refetches the rebels', () => { - const query = ` + const source = ` query RebelsRefetchQuery { node(id: "RmFjdGlvbjox") { id @@ -37,7 +37,7 @@ describe('Star Wars object identification', () => { } `; - expect(graphqlSync(StarWarsSchema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { node: { id: 'RmFjdGlvbjox', @@ -48,7 +48,7 @@ describe('Star Wars object identification', () => { }); it('fetches the ID and name of the empire', () => { - const query = ` + const source = ` query EmpireQuery { empire { id @@ -57,18 +57,15 @@ describe('Star Wars object identification', () => { } `; - expect(graphqlSync(StarWarsSchema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { - empire: { - id: 'RmFjdGlvbjoy', - name: 'Galactic Empire', - }, + empire: { id: 'RmFjdGlvbjoy', name: 'Galactic Empire' }, }, }); }); it('refetches the empire', () => { - const query = ` + const source = ` query EmpireRefetchQuery { node(id: "RmFjdGlvbjoy") { id @@ -79,18 +76,15 @@ describe('Star Wars object identification', () => { } `; - expect(graphqlSync(StarWarsSchema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { - node: { - id: 'RmFjdGlvbjoy', - name: 'Galactic Empire', - }, + node: { id: 'RmFjdGlvbjoy', name: 'Galactic Empire' }, }, }); }); it('refetches the X-Wing', () => { - const query = ` + const source = ` query XWingRefetchQuery { node(id: "U2hpcDox") { id @@ -101,12 +95,9 @@ describe('Star Wars object identification', () => { } `; - expect(graphqlSync(StarWarsSchema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { - node: { - id: 'U2hpcDox', - name: 'X-Wing', - }, + node: { id: 'U2hpcDox', name: 'X-Wing' }, }, }); }); diff --git a/src/connection/__tests__/connection.js b/src/connection/__tests__/connection.js index f8d5722..0f78cc7 100644 --- a/src/connection/__tests__/connection.js +++ b/src/connection/__tests__/connection.js @@ -88,7 +88,7 @@ const schema = new GraphQLSchema({ describe('connectionDefinition()', () => { it('includes connection and edge fields', () => { - const query = ` + const source = ` query FriendsQuery { user { friends(first: 2) { @@ -104,7 +104,7 @@ describe('connectionDefinition()', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { user: { friends: { @@ -126,7 +126,7 @@ describe('connectionDefinition()', () => { }); it('works with forwardConnectionArgs', () => { - const query = ` + const source = ` query FriendsQuery { user { friendsForward(first: 2) { @@ -140,18 +140,11 @@ describe('connectionDefinition()', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { user: { friendsForward: { - edges: [ - { - node: { name: 'Nick' }, - }, - { - node: { name: 'Lee' }, - }, - ], + edges: [{ node: { name: 'Nick' } }, { node: { name: 'Lee' } }], }, }, }, @@ -159,7 +152,7 @@ describe('connectionDefinition()', () => { }); it('works with backwardConnectionArgs', () => { - const query = ` + const source = ` query FriendsQuery { user { friendsBackward(last: 2) { @@ -173,18 +166,11 @@ describe('connectionDefinition()', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { user: { friendsBackward: { - edges: [ - { - node: { name: 'Joe' }, - }, - { - node: { name: 'Tim' }, - }, - ], + edges: [{ node: { name: 'Joe' } }, { node: { name: 'Tim' } }], }, }, }, diff --git a/src/mutation/__tests__/mutation.js b/src/mutation/__tests__/mutation.js index 5902909..c65d675 100644 --- a/src/mutation/__tests__/mutation.js +++ b/src/mutation/__tests__/mutation.js @@ -113,7 +113,7 @@ const schema = new GraphQLSchema({ describe('mutationWithClientMutationId()', () => { it('requires an argument', () => { - const query = ` + const source = ` mutation M { simpleMutation { result @@ -121,7 +121,7 @@ describe('mutationWithClientMutationId()', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ errors: [ { message: @@ -133,7 +133,7 @@ describe('mutationWithClientMutationId()', () => { }); it('returns the same client mutation ID', () => { - const query = ` + const source = ` mutation M { simpleMutation(input: {clientMutationId: "abc"}) { result @@ -142,7 +142,7 @@ describe('mutationWithClientMutationId()', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { simpleMutation: { result: 1, @@ -153,7 +153,7 @@ describe('mutationWithClientMutationId()', () => { }); it('supports thunks as input and output fields', () => { - const query = ` + const source = ` mutation M { simpleMutationWithThunkFields(input: { inputData: 1234, @@ -165,7 +165,7 @@ describe('mutationWithClientMutationId()', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { simpleMutationWithThunkFields: { result: 1234, @@ -176,7 +176,7 @@ describe('mutationWithClientMutationId()', () => { }); it('supports promise mutations', async () => { - const query = ` + const source = ` mutation M { simplePromiseMutation(input: {clientMutationId: "abc"}) { result @@ -185,7 +185,7 @@ describe('mutationWithClientMutationId()', () => { } `; - expect(await graphql(schema, query)).to.deep.equal({ + expect(await graphql({ schema, source })).to.deep.equal({ data: { simplePromiseMutation: { result: 1, @@ -196,7 +196,7 @@ describe('mutationWithClientMutationId()', () => { }); it('can access rootValue', () => { - const query = ` + const source = ` mutation M { simpleRootValueMutation(input: {clientMutationId: "abc"}) { result @@ -204,8 +204,9 @@ describe('mutationWithClientMutationId()', () => { } } `; + const rootValue = { result: 1 }; - expect(graphqlSync(schema, query, { result: 1 })).to.deep.equal({ + expect(graphqlSync({ schema, source, rootValue })).to.deep.equal({ data: { simpleRootValueMutation: { result: 1, @@ -216,7 +217,7 @@ describe('mutationWithClientMutationId()', () => { }); it('supports mutations returning null', () => { - const query = ` + const source = ` mutation M { simpleRootValueMutation(input: {clientMutationId: "abc"}) { result @@ -225,7 +226,7 @@ describe('mutationWithClientMutationId()', () => { } `; - expect(graphqlSync(schema, query, null)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { simpleRootValueMutation: { result: null, @@ -237,7 +238,7 @@ describe('mutationWithClientMutationId()', () => { describe('introspection', () => { it('contains correct input', () => { - const query = ` + const source = ` { __type(name: "SimpleMutationInput") { name @@ -253,7 +254,7 @@ describe('mutationWithClientMutationId()', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { __type: { name: 'SimpleMutationInput', @@ -273,7 +274,7 @@ describe('mutationWithClientMutationId()', () => { }); it('contains correct payload', () => { - const query = ` + const source = ` { __type(name: "SimpleMutationPayload") { name @@ -289,7 +290,7 @@ describe('mutationWithClientMutationId()', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { __type: { name: 'SimpleMutationPayload', @@ -316,7 +317,7 @@ describe('mutationWithClientMutationId()', () => { }); it('contains correct field', () => { - const query = ` + const source = ` { __schema { mutationType { @@ -343,7 +344,7 @@ describe('mutationWithClientMutationId()', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { __schema: { mutationType: { @@ -456,7 +457,7 @@ describe('mutationWithClientMutationId()', () => { }); it('contains correct descriptions', () => { - const query = ` + const source = ` { __schema { mutationType { @@ -469,7 +470,7 @@ describe('mutationWithClientMutationId()', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { __schema: { mutationType: { @@ -502,7 +503,7 @@ describe('mutationWithClientMutationId()', () => { }); it('contains correct deprecation reasons', () => { - const query = ` + const source = ` { __schema { mutationType { @@ -516,7 +517,7 @@ describe('mutationWithClientMutationId()', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { __schema: { mutationType: { diff --git a/src/node/__tests__/global.js b/src/node/__tests__/global.js index aa256ea..e71505b 100644 --- a/src/node/__tests__/global.js +++ b/src/node/__tests__/global.js @@ -130,7 +130,7 @@ const schema = new GraphQLSchema({ describe('global ID fields', () => { it('gives different IDs', () => { - const query = ` + const source = ` { allObjects { id @@ -138,7 +138,7 @@ describe('global ID fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { allObjects: [ { id: 'VXNlcjox' }, @@ -153,7 +153,7 @@ describe('global ID fields', () => { }); it('refetches the IDs', () => { - const query = ` + const source = ` { user: node(id: "VXNlcjox") { id @@ -176,7 +176,7 @@ describe('global ID fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { user: { id: 'VXNlcjox', diff --git a/src/node/__tests__/node.js b/src/node/__tests__/node.js index 677d0bd..3ad1400 100644 --- a/src/node/__tests__/node.js +++ b/src/node/__tests__/node.js @@ -98,7 +98,7 @@ const schema = new GraphQLSchema({ describe('Node interface and fields', () => { describe('refetchability', () => { it('gets the correct ID for users', () => { - const query = ` + const source = ` { node(id: "1") { id @@ -106,7 +106,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { node: { id: '1' }, }, @@ -114,7 +114,7 @@ describe('Node interface and fields', () => { }); it('gets the correct IDs for users', () => { - const query = ` + const source = ` { nodes(ids: ["1", "2"]) { id @@ -122,7 +122,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { nodes: [{ id: '1' }, { id: '2' }], }, @@ -130,7 +130,7 @@ describe('Node interface and fields', () => { }); it('gets the correct ID for photos', () => { - const query = ` + const source = ` { node(id: "4") { id @@ -138,7 +138,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { node: { id: '4' }, }, @@ -146,7 +146,7 @@ describe('Node interface and fields', () => { }); it('gets the correct IDs for photos', () => { - const query = ` + const source = ` { nodes(ids: ["3", "4"]) { id @@ -154,7 +154,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { nodes: [{ id: '3' }, { id: '4' }], }, @@ -162,7 +162,7 @@ describe('Node interface and fields', () => { }); it('gets the correct IDs for multiple types', () => { - const query = ` + const source = ` { nodes(ids: ["1", "3"]) { id @@ -170,7 +170,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { nodes: [{ id: '1' }, { id: '3' }], }, @@ -178,7 +178,7 @@ describe('Node interface and fields', () => { }); it('gets the correct name for users', () => { - const query = ` + const source = ` { node(id: "1") { id @@ -189,7 +189,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { node: { id: '1', @@ -200,7 +200,7 @@ describe('Node interface and fields', () => { }); it('gets the correct width for photos', () => { - const query = ` + const source = ` { node(id: "4") { id @@ -211,7 +211,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { node: { id: '4', @@ -222,7 +222,7 @@ describe('Node interface and fields', () => { }); it('gets the correct type name for users', () => { - const query = ` + const source = ` { node(id: "1") { id @@ -231,7 +231,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { node: { id: '1', @@ -242,7 +242,7 @@ describe('Node interface and fields', () => { }); it('gets the correct type name for photos', () => { - const query = ` + const source = ` { node(id: "4") { id @@ -251,7 +251,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { node: { id: '4', @@ -262,7 +262,7 @@ describe('Node interface and fields', () => { }); it('ignores photo fragments on user', () => { - const query = ` + const source = ` { node(id: "1") { id @@ -273,7 +273,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { node: { id: '1' }, }, @@ -281,7 +281,7 @@ describe('Node interface and fields', () => { }); it('returns null for bad IDs', () => { - const query = ` + const source = ` { node(id: "5") { id @@ -289,7 +289,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { node: null, }, @@ -297,7 +297,7 @@ describe('Node interface and fields', () => { }); it('returns nulls for bad IDs', () => { - const query = ` + const source = ` { nodes(ids: ["3", "5"]) { id @@ -305,7 +305,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { nodes: [{ id: '3' }, null], }, @@ -315,7 +315,7 @@ describe('Node interface and fields', () => { describe('introspection', () => { it('has correct node interface', () => { - const query = ` + const source = ` { __type(name: "Node") { name @@ -334,7 +334,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { __type: { name: 'Node', @@ -357,7 +357,7 @@ describe('Node interface and fields', () => { }); it('has correct node and nodes root fields', () => { - const query = ` + const source = ` { __schema { queryType { @@ -383,7 +383,7 @@ describe('Node interface and fields', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { __schema: { queryType: { diff --git a/src/node/__tests__/nodeasync.js b/src/node/__tests__/nodeasync.js index 72e90f5..8e2aff5 100644 --- a/src/node/__tests__/nodeasync.js +++ b/src/node/__tests__/nodeasync.js @@ -55,7 +55,7 @@ const schema = new GraphQLSchema({ describe('Node interface and fields with async object fetcher', () => { it('gets the correct ID for users', async () => { - const query = ` + const source = ` { node(id: "1") { id @@ -63,17 +63,15 @@ describe('Node interface and fields with async object fetcher', () => { } `; - expect(await graphql(schema, query)).to.deep.equal({ + expect(await graphql({ schema, source })).to.deep.equal({ data: { - node: { - id: '1', - }, + node: { id: '1' }, }, }); }); it('gets the correct name for users', async () => { - const query = ` + const source = ` { node(id: "1") { id @@ -84,12 +82,9 @@ describe('Node interface and fields with async object fetcher', () => { } `; - expect(await graphql(schema, query)).to.deep.equal({ + expect(await graphql({ schema, source })).to.deep.equal({ data: { - node: { - id: '1', - name: 'John Doe', - }, + node: { id: '1', name: 'John Doe' }, }, }); }); diff --git a/src/node/__tests__/plural.js b/src/node/__tests__/plural.js index b213e96..05a7604 100644 --- a/src/node/__tests__/plural.js +++ b/src/node/__tests__/plural.js @@ -42,11 +42,9 @@ const schema = new GraphQLSchema({ query: queryType, }); -const context = { lang: 'en' }; - describe('pluralIdentifyingRootField()', () => { it('allows fetching', () => { - const query = ` + const source = ` { usernames(usernames:[ "dschafer", "leebyron", "schrockn" ]) { username @@ -55,7 +53,8 @@ describe('pluralIdentifyingRootField()', () => { } `; - expect(graphqlSync(schema, query, null, context)).to.deep.equal({ + const contextValue = { lang: 'en' }; + expect(graphqlSync({ schema, source, contextValue })).to.deep.equal({ data: { usernames: [ { @@ -76,7 +75,7 @@ describe('pluralIdentifyingRootField()', () => { }); it('correctly introspects', () => { - const query = ` + const source = ` { __schema { queryType { @@ -111,7 +110,7 @@ describe('pluralIdentifyingRootField()', () => { } `; - expect(graphqlSync(schema, query)).to.deep.equal({ + expect(graphqlSync({ schema, source })).to.deep.equal({ data: { __schema: { queryType: {