diff --git a/packages/batch-delegate/tests/basic.example.test.ts b/packages/batch-delegate/tests/basic.example.test.ts index 8fe5827636d..fa30e35cf49 100644 --- a/packages/batch-delegate/tests/basic.example.test.ts +++ b/packages/batch-delegate/tests/basic.example.test.ts @@ -1,4 +1,4 @@ -import { execute } from '@graphql-tools/executor'; +import { execute, isIncrementalResult } from '@graphql-tools/executor'; import { OperationTypeNode, parse } from 'graphql'; import { makeExecutableSchema } from '@graphql-tools/schema'; @@ -89,6 +89,9 @@ describe('batch delegation within basic stitching example', () => { const result = await execute({ schema: stitchedSchema, document: parse(query) }); expect(numCalls).toEqual(1); + + if (isIncrementalResult(result)) throw Error('result is incremental'); + expect(result.errors).toBeUndefined(); const chirps: any = result.data!['trendingChirps']; expect(chirps[0].chirpedAtUser.email).not.toBe(null); @@ -182,6 +185,9 @@ describe('batch delegation within basic stitching example', () => { const result = await execute({ schema: stitchedSchema, document: parse(query) }); expect(numCalls).toEqual(1); + + if (isIncrementalResult(result)) throw Error('result is incremental'); + expect(result.data).toEqual({ users: [ { diff --git a/packages/batch-delegate/tests/withTransforms.test.ts b/packages/batch-delegate/tests/withTransforms.test.ts index c8e4122621a..754c5b238f9 100644 --- a/packages/batch-delegate/tests/withTransforms.test.ts +++ b/packages/batch-delegate/tests/withTransforms.test.ts @@ -1,4 +1,4 @@ -import { execute } from '@graphql-tools/executor'; +import { execute, isIncrementalResult } from '@graphql-tools/executor'; import { GraphQLList, GraphQLObjectType, Kind, OperationTypeNode, parse } from 'graphql'; import { makeExecutableSchema } from '@graphql-tools/schema'; @@ -121,6 +121,7 @@ describe('works with complex transforms', () => { `; const result = await execute({ schema: stitchedSchema, document: parse(query) }); + if (isIncrementalResult(result)) throw Error('result is incremental'); expect(result.errors).toBeUndefined(); expect(result.data).toEqual({ diff --git a/packages/executor/src/execution/__tests__/defer-test.ts b/packages/executor/src/execution/__tests__/defer-test.ts index 43646ee9f24..bff9036f2d4 100644 --- a/packages/executor/src/execution/__tests__/defer-test.ts +++ b/packages/executor/src/execution/__tests__/defer-test.ts @@ -10,10 +10,9 @@ import { } from 'graphql'; import { expectJSON } from '../../__testUtils__/expectJSON.js'; import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick.js'; -import { expectPromise } from '../../__testUtils__/expectPromise.js'; import type { InitialIncrementalExecutionResult, SubsequentIncrementalExecutionResult } from '../execute.js'; -import { execute, experimentalExecuteIncrementally } from '../execute.js'; +import { execute } from '../execute.js'; const friendType = new GraphQLObjectType({ fields: { @@ -87,7 +86,7 @@ const query = new GraphQLObjectType({ const schema = new GraphQLSchema({ query }); async function complete(document: DocumentNode) { - const result = await experimentalExecuteIncrementally({ + const result = await execute({ schema, document, rootValue: {}, @@ -698,46 +697,4 @@ describe('Execute: defer directive', () => { ], }); }); - - it('original execute function throws error if anything is deferred and everything else is sync', () => { - const doc = ` - query Deferred { - ... @defer { hero { id } } - } - `; - expect(() => - execute({ - schema, - document: parse(doc), - rootValue: {}, - }) - ).toThrow( - 'Executing this GraphQL operation would unexpectedly produce multiple payloads (due to @defer or @stream directive)' - ); - }); - - it('original execute function resolves to error if anything is deferred and something else is async', async () => { - const doc = ` - query Deferred { - hero { slowField } - ... @defer { hero { id } } - } - `; - expectJSON( - await expectPromise( - execute({ - schema, - document: parse(doc), - rootValue: {}, - }) - ).toResolve() - ).toDeepEqual({ - errors: [ - { - message: - 'Executing this GraphQL operation would unexpectedly produce multiple payloads (due to @defer or @stream directive)', - }, - ], - }); - }); }); diff --git a/packages/executor/src/execution/__tests__/mutations-test.ts b/packages/executor/src/execution/__tests__/mutations-test.ts index 9f6b4865bba..2a43216e331 100644 --- a/packages/executor/src/execution/__tests__/mutations-test.ts +++ b/packages/executor/src/execution/__tests__/mutations-test.ts @@ -1,7 +1,7 @@ import { parse, GraphQLObjectType, GraphQLInt, GraphQLSchema } from 'graphql'; import { expectJSON } from '../../__testUtils__/expectJSON.js'; import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick.js'; -import { execute, executeSync, experimentalExecuteIncrementally } from '../execute.js'; +import { execute, executeSync } from '../execute.js'; class NumberHolder { theNumber: number; @@ -206,7 +206,7 @@ describe('Execute: Handles mutation execution ordering', () => { `); const rootValue = new Root(6); - const mutationResult = await experimentalExecuteIncrementally({ + const mutationResult = await execute({ schema, document, rootValue, @@ -286,7 +286,7 @@ describe('Execute: Handles mutation execution ordering', () => { `); const rootValue = new Root(6); - const mutationResult = await experimentalExecuteIncrementally({ + const mutationResult = await execute({ schema, document, rootValue, diff --git a/packages/executor/src/execution/__tests__/stream-test.ts b/packages/executor/src/execution/__tests__/stream-test.ts index 0be15881055..d1308d3d486 100644 --- a/packages/executor/src/execution/__tests__/stream-test.ts +++ b/packages/executor/src/execution/__tests__/stream-test.ts @@ -11,7 +11,7 @@ import { } from 'graphql'; import { expectJSON } from '../../__testUtils__/expectJSON.js'; import type { InitialIncrementalExecutionResult, SubsequentIncrementalExecutionResult } from '../execute.js'; -import { experimentalExecuteIncrementally } from '../execute.js'; +import { execute } from '../execute.js'; const friendType = new GraphQLObjectType({ fields: { @@ -74,7 +74,7 @@ const query = new GraphQLObjectType({ const schema = new GraphQLSchema({ query }); async function complete(document: DocumentNode, rootValue: unknown = {}) { - const result = await experimentalExecuteIncrementally({ + const result = await execute({ schema, document, rootValue, @@ -93,7 +93,7 @@ async function complete(document: DocumentNode, rootValue: unknown = {}) { } async function completeAsync(document: DocumentNode, numCalls: number, rootValue: unknown = {}) { - const result = await experimentalExecuteIncrementally({ + const result = await execute({ schema, document, rootValue, @@ -1304,7 +1304,7 @@ describe('Execute: stream directive', () => { } `); - const executeResult = await experimentalExecuteIncrementally({ + const executeResult = await execute({ schema, document, rootValue: { @@ -1423,7 +1423,7 @@ describe('Execute: stream directive', () => { } } `); - const executeResult = await experimentalExecuteIncrementally({ + const executeResult = await execute({ schema, document, rootValue: { @@ -1518,7 +1518,7 @@ describe('Execute: stream directive', () => { } `); - const executeResult = await experimentalExecuteIncrementally({ + const executeResult = await execute({ schema, document, rootValue: { @@ -1606,7 +1606,7 @@ describe('Execute: stream directive', () => { } `); - const executeResult = await experimentalExecuteIncrementally({ + const executeResult = await execute({ schema, document, rootValue: { @@ -1713,7 +1713,7 @@ describe('Execute: stream directive', () => { } `); - const executeResult = await experimentalExecuteIncrementally({ + const executeResult = await execute({ schema, document, rootValue: { @@ -1769,7 +1769,7 @@ describe('Execute: stream directive', () => { } `); - const executeResult = await experimentalExecuteIncrementally({ + const executeResult = await execute({ schema, document, rootValue: { @@ -1831,7 +1831,7 @@ describe('Execute: stream directive', () => { } `); - const executeResult = await experimentalExecuteIncrementally({ + const executeResult = await execute({ schema, document, rootValue: { diff --git a/packages/executor/src/execution/execute.ts b/packages/executor/src/execution/execute.ts index 6678950bdf5..3efafe9e864 100644 --- a/packages/executor/src/execution/execute.ts +++ b/packages/executor/src/execution/execute.ts @@ -114,10 +114,7 @@ export interface FormattedExecutionResult, TExte extensions?: TExtensions; } -export interface ExperimentalIncrementalExecutionResults< - TData = Record, - TExtensions = Record -> { +export interface IncrementalExecutionResults, TExtensions = Record> { initialResult: InitialIncrementalExecutionResult; subsequentResults: AsyncGenerator, void, void>; } @@ -209,58 +206,21 @@ export interface ExecutionArgs { const UNEXPECTED_MULTIPLE_PAYLOADS = 'Executing this GraphQL operation would unexpectedly produce multiple payloads (due to @defer or @stream directive)'; -/** - * Implements the "Executing requests" section of the GraphQL specification. - * - * Returns either a synchronous ExecutionResult (if all encountered resolvers - * are synchronous), or a Promise of an ExecutionResult that will eventually be - * resolved and never rejected. - * - * If the arguments to this function do not result in a legal execution context, - * a GraphQLError will be thrown immediately explaining the invalid input. - * - * This function does not support incremental delivery (`@defer` and `@stream`). - * If an operation which would defer or stream data is executed with this - * function, it will throw or resolve to an object containing an error instead. - * Use `experimentalExecuteIncrementally` if you want to support incremental - * delivery. - */ -export function execute( - args: ExecutionArgs -): MaybePromise> { - const result = experimentalExecuteIncrementally(args); - if (!isPromise(result)) { - if ('initialResult' in result) { - throw new Error(UNEXPECTED_MULTIPLE_PAYLOADS); - } - return result; - } - - return result.then(incrementalResult => { - if ('initialResult' in incrementalResult) { - return { - errors: [createGraphQLError(UNEXPECTED_MULTIPLE_PAYLOADS)], - }; - } - return incrementalResult; - }); -} - /** * Implements the "Executing requests" section of the GraphQL specification, * including `@defer` and `@stream` as proposed in * https://github.com/graphql/graphql-spec/pull/742 * - * This function returns a Promise of an ExperimentalIncrementalExecutionResults + * This function returns a Promise of an IncrementalExecutionResults * object. This object either consists of a single ExecutionResult, or an * object containing an `initialResult` and a stream of `subsequentResults`. * * If the arguments to this function do not result in a legal execution context, * a GraphQLError will be thrown immediately explaining the invalid input. */ -export function experimentalExecuteIncrementally( +export function execute( args: ExecutionArgs -): MaybePromise | ExperimentalIncrementalExecutionResults> { +): MaybePromise | IncrementalExecutionResults> { // If a valid execution context cannot be created due to incorrect arguments, // a "Response" with only errors is returned. const exeContext = buildExecutionContext(args); @@ -275,7 +235,7 @@ export function experimentalExecuteIncrementally( exeContext: ExecutionContext -): MaybePromise | ExperimentalIncrementalExecutionResults> { +): MaybePromise | IncrementalExecutionResults> { // Return a Promise that will eventually resolve to the data described by // The "Response" section of the GraphQL specification. // @@ -333,7 +293,7 @@ function executeImpl( * that all field resolvers are also synchronous. */ export function executeSync(args: ExecutionArgs): ExecutionResult { - const result = experimentalExecuteIncrementally(args); + const result = execute(args); // Assert that the execution was synchronous. if (isPromise(result) || 'initialResult' in result) { @@ -1375,7 +1335,7 @@ export function experimentalSubscribeIncrementally( } async function* ensureAsyncIterable( - someExecutionResult: ExecutionResult | ExperimentalIncrementalExecutionResults + someExecutionResult: ExecutionResult | IncrementalExecutionResults ): AsyncGenerator< ExecutionResult | InitialIncrementalExecutionResult | SubsequentIncrementalExecutionResult, void, @@ -2008,3 +1968,9 @@ export function getFieldDef( } return parentType.getFields()[fieldName]; } + +export function isIncrementalResult( + result: ExecutionResult | IncrementalExecutionResults +): result is IncrementalExecutionResults { + return 'incremental' in result; +} diff --git a/packages/loaders/url/tests/graphql-upload.spec.ts b/packages/loaders/url/tests/graphql-upload.spec.ts index cf0e968cf7c..ee1fae644f2 100644 --- a/packages/loaders/url/tests/graphql-upload.spec.ts +++ b/packages/loaders/url/tests/graphql-upload.spec.ts @@ -1,6 +1,6 @@ import { File } from '@whatwg-node/fetch'; import { readFileSync } from 'fs'; -import { execute } from '@graphql-tools/executor'; +import { execute, isIncrementalResult } from '@graphql-tools/executor'; import { GraphQLSchema, parse } from 'graphql'; import { join } from 'path'; import { assertNonMaybe, testSchema } from './test-utils'; @@ -85,7 +85,7 @@ describe('GraphQL Upload compatibility', () => { nonObjectVar: 'somefilename.txt', }, }); - + if (isIncrementalResult(result)) throw Error('result is incremental'); expect(result.errors).toBeFalsy(); assertNonMaybe(result.data); const uploadFileData: any = result.data?.['uploadFile']; diff --git a/packages/loaders/url/tests/url-loader.spec.ts b/packages/loaders/url/tests/url-loader.spec.ts index ab974adeb7d..830220d9006 100644 --- a/packages/loaders/url/tests/url-loader.spec.ts +++ b/packages/loaders/url/tests/url-loader.spec.ts @@ -11,7 +11,7 @@ import { AsyncFetchFn, defaultAsyncFetch } from '../src/defaultAsyncFetch.js'; import { Response, Headers } from '@whatwg-node/fetch'; import { loadSchema } from '@graphql-tools/load'; import { testUrl, testSchema, testTypeDefs, assertNonMaybe } from './test-utils'; -import { execute, subscribe } from '@graphql-tools/executor'; +import { execute, isIncrementalResult, subscribe } from '@graphql-tools/executor'; describe('Schema URL Loader', () => { const loader = new UrlLoader(); @@ -180,6 +180,8 @@ describe('Schema URL Loader', () => { }, }); + if (isIncrementalResult(result)) throw Error('result is incremental'); + expect(result?.errors).toBeFalsy(); expect(result?.data?.['a']).toBe(testVariableValue); diff --git a/packages/resolvers-composition/tests/resolvers-composition.spec.ts b/packages/resolvers-composition/tests/resolvers-composition.spec.ts index cf26590d2dc..fb765c16082 100644 --- a/packages/resolvers-composition/tests/resolvers-composition.spec.ts +++ b/packages/resolvers-composition/tests/resolvers-composition.spec.ts @@ -1,7 +1,7 @@ import gql from 'graphql-tag'; import { composeResolvers, ResolversComposerMapping } from '../src/index.js'; import { makeExecutableSchema } from '@graphql-tools/schema'; -import { execute } from '@graphql-tools/executor'; +import { execute, isIncrementalResult } from '@graphql-tools/executor'; import { GraphQLScalarType, Kind } from 'graphql'; import { inspect } from '@graphql-tools/utils'; @@ -55,6 +55,7 @@ describe('Resolvers composition', () => { } `, }); + if (isIncrementalResult(result)) throw Error('result is incremental'); expect(result.errors).toBeFalsy(); expect(result.data!['foo']).toBe('FOOFOO'); }); @@ -95,6 +96,7 @@ describe('Resolvers composition', () => { } `, }); + if (isIncrementalResult(result)) throw Error('result is incremental'); expect(result.errors).toBeFalsy(); expect(result.data!['foo']).toBe('FOOFOO'); }); @@ -174,6 +176,7 @@ describe('Resolvers composition', () => { } `, }); + if (isIncrementalResult(result)) throw Error('result is incremental'); expect(result.errors).toBeFalsy(); expect(result.data!['foo']).toBe('FOOFOO'); }); diff --git a/packages/schema/tests/schemaGenerator.test.ts b/packages/schema/tests/schemaGenerator.test.ts index 40b970de0d4..7ba53d29e8a 100644 --- a/packages/schema/tests/schemaGenerator.test.ts +++ b/packages/schema/tests/schemaGenerator.test.ts @@ -23,7 +23,7 @@ import { makeExecutableSchema, addResolversToSchema, chainResolvers } from '@gra import { IResolverValidationOptions, IResolvers, ExecutionResult, TypeSource } from '@graphql-tools/utils'; import TypeA from './fixtures/circularSchemaA.js'; -import { execute } from '@graphql-tools/executor'; +import { execute, isIncrementalResult } from '@graphql-tools/executor'; interface Bird { name: string; @@ -2045,6 +2045,7 @@ describe('can specify lexical parser options', () => { const hoistedQuery = hoist(parsedQuery); const result = await execute({ schema: jsSchema, document: hoistedQuery }); + if (isIncrementalResult(result)) throw Error('result is incremental'); expect(result.data).toEqual({ hello: 'hello world' }); const result2 = await execute({ @@ -2054,6 +2055,7 @@ describe('can specify lexical parser options', () => { phrase: 'world again!', }, }); + if (isIncrementalResult(result2)) throw Error('result is incremental'); expect(result2.data).toEqual({ hello: 'hello world again!' }); }); }); diff --git a/packages/wrap/tests/transformFilterInputObjectFields.test.ts b/packages/wrap/tests/transformFilterInputObjectFields.test.ts index fde82e46f68..733cbeb135a 100644 --- a/packages/wrap/tests/transformFilterInputObjectFields.test.ts +++ b/packages/wrap/tests/transformFilterInputObjectFields.test.ts @@ -2,7 +2,7 @@ import { wrapSchema, FilterInputObjectFields } from '@graphql-tools/wrap'; import { makeExecutableSchema } from '@graphql-tools/schema'; import { graphql, astFromValue, Kind, GraphQLString, parse } from 'graphql'; import { assertSome } from '@graphql-tools/utils'; -import { execute } from '@graphql-tools/executor'; +import { execute, isIncrementalResult } from '@graphql-tools/executor'; describe('FilterInputObjectFields', () => { const schema = makeExecutableSchema({ @@ -73,6 +73,7 @@ describe('FilterInputObjectFields', () => { schema: transformedSchema, document: parse(query), }); + if (isIncrementalResult(result)) throw Error('result is incremental'); assertSome(result.data); expect(result.errors).toBeUndefined(); const dataTest: any = result.data['test']; diff --git a/packages/wrap/tests/transformMapLeafValues.test.ts b/packages/wrap/tests/transformMapLeafValues.test.ts index f8e3de67ffb..3e6d9f61648 100644 --- a/packages/wrap/tests/transformMapLeafValues.test.ts +++ b/packages/wrap/tests/transformMapLeafValues.test.ts @@ -1,6 +1,6 @@ import { wrapSchema, MapLeafValues } from '@graphql-tools/wrap'; import { makeExecutableSchema } from '@graphql-tools/schema'; -import { execute } from '@graphql-tools/executor'; +import { execute, isIncrementalResult } from '@graphql-tools/executor'; import { GraphQLSchema, parse } from 'graphql'; import { assertSome } from '@graphql-tools/utils'; @@ -55,6 +55,8 @@ describe('MapLeafValues', () => { schema: transformedSchema, document: parse(query), }); + if (isIncrementalResult(result)) throw Error('result is incremental'); + assertSome(result.data); expect(result.data['testEnum']).toBe('THREE'); expect(result.data['testScalar']).toBe(15); @@ -74,6 +76,7 @@ describe('MapLeafValues', () => { argument: 5, }, }); + if (isIncrementalResult(result)) throw Error('result is incremental'); assertSome(result.data); expect(result.data['testEnum']).toBe('THREE'); expect(result.data['testScalar']).toBe(15); diff --git a/packages/wrap/tests/transformRenameInputObjectFields.test.ts b/packages/wrap/tests/transformRenameInputObjectFields.test.ts index b2756bbd491..b883227a4ed 100644 --- a/packages/wrap/tests/transformRenameInputObjectFields.test.ts +++ b/packages/wrap/tests/transformRenameInputObjectFields.test.ts @@ -1,6 +1,6 @@ import { wrapSchema, RenameInputObjectFields } from '@graphql-tools/wrap'; import { makeExecutableSchema } from '@graphql-tools/schema'; -import { execute } from '@graphql-tools/executor'; +import { execute, isIncrementalResult } from '@graphql-tools/executor'; import { parse } from 'graphql'; import { assertSome } from '@graphql-tools/utils'; @@ -55,6 +55,7 @@ describe('RenameInputObjectFields', () => { schema: transformedSchema, document: parse(query), }); + if (isIncrementalResult(result)) throw Error('result is incremental'); assertSome(result.data); const testData: any = result.data['test']; expect(testData.field1).toBe('field1'); @@ -111,6 +112,8 @@ describe('RenameInputObjectFields', () => { schema: transformedSchema, document: parse(query), }); + if (isIncrementalResult(result)) throw Error('result is incremental'); + assertSome(result.data); const testData: any = result.data['test']; expect(testData.field1).toBe('field1'); @@ -176,6 +179,7 @@ describe('RenameInputObjectFields', () => { }, }; const result = await execute({ schema: transformedSchema, document: parse(query), variableValues: variables }); + if (isIncrementalResult(result)) throw Error('result is incremental'); assertSome(result.data); const testData: any = result.data['test']; expect(testData.field1).toBe('field1'); diff --git a/packages/wrap/tests/transformRenameObjectFieldArguments.test.ts b/packages/wrap/tests/transformRenameObjectFieldArguments.test.ts index 48c28674236..8122e883d02 100644 --- a/packages/wrap/tests/transformRenameObjectFieldArguments.test.ts +++ b/packages/wrap/tests/transformRenameObjectFieldArguments.test.ts @@ -1,6 +1,6 @@ import { wrapSchema } from '@graphql-tools/wrap'; import { makeExecutableSchema } from '@graphql-tools/schema'; -import { execute } from '@graphql-tools/executor'; +import { execute, isIncrementalResult } from '@graphql-tools/executor'; import { parse } from 'graphql'; import { assertSome } from '@graphql-tools/utils'; @@ -58,6 +58,8 @@ describe('RenameObjectFieldArguments', () => { schema: transformedSchema, document: parse(query), }); + if (isIncrementalResult(result)) throw Error('result is incremental'); + assertSome(result.data); const testData: any = result.data['test']; expect(testData.field1).toBe('field1'); @@ -124,6 +126,7 @@ describe('RenameObjectFieldArguments', () => { }, }; const result = await execute({ schema: transformedSchema, document: parse(query), variableValues: variables }); + if (isIncrementalResult(result)) throw Error('result is incremental'); assertSome(result.data); const testData: any = result.data['test']; expect(testData.field1).toBe('field1'); diff --git a/packages/wrap/tests/transformTransformCompositeFields.test.ts b/packages/wrap/tests/transformTransformCompositeFields.test.ts index 63424f2f5c6..69a70e8131b 100644 --- a/packages/wrap/tests/transformTransformCompositeFields.test.ts +++ b/packages/wrap/tests/transformTransformCompositeFields.test.ts @@ -1,7 +1,7 @@ import { wrapSchema, TransformCompositeFields } from '@graphql-tools/wrap'; import { makeExecutableSchema } from '@graphql-tools/schema'; import { parse } from 'graphql'; -import { execute } from '@graphql-tools/executor'; +import { execute, isIncrementalResult } from '@graphql-tools/executor'; const baseSchema = makeExecutableSchema({ typeDefs: /* GraphQL */ ` @@ -35,6 +35,7 @@ describe('TransformCompositeFields', () => { schema: transformedSchema, document: parse('{ product { id, theId: id } }'), }); + if (isIncrementalResult(result)) throw Error('result is incremental'); expect(result.data).toEqual({ product: { id: 'r2d2c3p0', theId: 'r2d2c3p0' }, }); @@ -65,6 +66,7 @@ describe('TransformCompositeFields', () => { schema: transformedSchema, document: parse('{ product { theId: id } }'), }); + if (isIncrementalResult(result)) throw Error('result is incremental'); expect(result.data).toEqual({ product: { theId: 'R2D2C3P0' }, }); @@ -91,6 +93,7 @@ describe('TransformCompositeFields', () => { schema: transformedSchema, document: parse('{ product { _id } }'), }); + if (isIncrementalResult(result)) throw Error('result is incremental'); expect(dataObjects).toEqual(['Query', 'Product']); expect(result.data).toEqual({ product: { _id: 'R2D2C3P0' }, diff --git a/packages/wrap/tests/transformTransformEnumValues.test.ts b/packages/wrap/tests/transformTransformEnumValues.test.ts index 62b272fd4a7..9d4776354e7 100644 --- a/packages/wrap/tests/transformTransformEnumValues.test.ts +++ b/packages/wrap/tests/transformTransformEnumValues.test.ts @@ -1,7 +1,7 @@ import { wrapSchema, TransformEnumValues } from '@graphql-tools/wrap'; import { makeExecutableSchema } from '@graphql-tools/schema'; import { GraphQLEnumType, parse } from 'graphql'; -import { execute } from '@graphql-tools/executor'; +import { execute, isIncrementalResult } from '@graphql-tools/executor'; function assertGraphQLEnumType(input: unknown): asserts input is GraphQLEnumType { if (input instanceof GraphQLEnumType) { @@ -44,6 +44,7 @@ describe('TransformEnumValues', () => { schema: transformedSchema, document: parse(query), }); + if (isIncrementalResult(result)) throw Error('result is incremental'); expect(result.errors).toBeUndefined(); }); @@ -88,6 +89,7 @@ describe('TransformEnumValues', () => { schema: transformedSchema, document: parse(query), }); + if (isIncrementalResult(result)) throw Error('result is incremental'); expect(result.errors).toBeUndefined(); const TestEnum = transformedSchema.getType('TestEnum'); assertGraphQLEnumType(TestEnum); @@ -130,6 +132,7 @@ describe('TransformEnumValues', () => { test: 'UNO', }, }); + if (isIncrementalResult(result)) throw Error('result is incremental'); expect(result.errors).toBeUndefined(); }); });