@@ -14,7 +14,7 @@ import { GraphQLList, GraphQLObjectType } from '../../type/definition';
1414import { GraphQLBoolean , GraphQLInt , GraphQLString } from '../../type/scalars' ;
1515import { GraphQLSchema } from '../../type/schema' ;
1616
17- import type { ExecutionResult } from '../execute' ;
17+ import type { ExecutionArgs , ExecutionResult } from '../execute' ;
1818import { createSourceEventStream , subscribe } from '../execute' ;
1919
2020import { SimplePubSub } from './simplePubSub' ;
@@ -195,6 +195,15 @@ function subscribeWithBadFn(
195195 ) ;
196196}
197197
198+ function subscribeWithBadArgs (
199+ args : ExecutionArgs ,
200+ ) : PromiseOrValue < ExecutionResult | AsyncIterable < unknown > > {
201+ return expectEqualPromisesOrValues (
202+ subscribe ( args ) ,
203+ createSourceEventStream ( args ) ,
204+ ) ;
205+ }
206+
198207/* eslint-disable @typescript-eslint/require-await */
199208// Check all error cases when initializing the subscription.
200209describe ( 'Subscription Initialization Phase' , ( ) => {
@@ -394,7 +403,7 @@ describe('Subscription Initialization Phase', () => {
394403 const schema = new GraphQLSchema ( { query : DummyQueryType } ) ;
395404 const document = parse ( 'subscription { unknownField }' ) ;
396405
397- const result = subscribe ( { schema, document } ) ;
406+ const result = subscribeWithBadArgs ( { schema, document } ) ;
398407 expectJSON ( result ) . toDeepEqual ( {
399408 errors : [
400409 {
@@ -418,7 +427,7 @@ describe('Subscription Initialization Phase', () => {
418427 } ) ;
419428 const document = parse ( 'subscription { unknownField }' ) ;
420429
421- const result = subscribe ( { schema, document } ) ;
430+ const result = subscribeWithBadArgs ( { schema, document } ) ;
422431 expectJSON ( result ) . toDeepEqual ( {
423432 errors : [
424433 {
@@ -441,7 +450,7 @@ describe('Subscription Initialization Phase', () => {
441450 } ) ;
442451
443452 // @ts -expect-error
444- expect ( ( ) => subscribe ( { schema, document : { } } ) ) . to . throw ( ) ;
453+ expect ( ( ) => subscribeWithBadArgs ( { schema, document : { } } ) ) . to . throw ( ) ;
445454 } ) ;
446455
447456 it ( 'throws an error if subscribe does not return an iterator' , async ( ) => {
@@ -526,7 +535,7 @@ describe('Subscription Initialization Phase', () => {
526535
527536 // If we receive variables that cannot be coerced correctly, subscribe() will
528537 // resolve to an ExecutionResult that contains an informative error description.
529- const result = subscribe ( { schema, document, variableValues } ) ;
538+ const result = subscribeWithBadArgs ( { schema, document, variableValues } ) ;
530539 expectJSON ( result ) . toDeepEqual ( {
531540 errors : [
532541 {
0 commit comments