11import { inspect } from '../jsutils/inspect' ;
22import { isAsyncIterable } from '../jsutils/isAsyncIterable' ;
33import { isPromise } from '../jsutils/isPromise' ;
4- import type { Maybe } from '../jsutils/Maybe' ;
54import { addPath , pathToArray } from '../jsutils/Path' ;
65import type { PromiseOrValue } from '../jsutils/PromiseOrValue' ;
76
87import { GraphQLError } from '../error/GraphQLError' ;
98import { locatedError } from '../error/locatedError' ;
109
11- import type { DocumentNode } from '../language/ast' ;
12-
13- import type { GraphQLFieldResolver } from '../type/definition' ;
14- import type { GraphQLSchema } from '../type/schema' ;
15-
1610import { collectFields } from './collectFields' ;
1711import type {
1812 ExecutionArgs ,
@@ -89,36 +83,6 @@ function mapSourceToResponse(
8983 ) ;
9084}
9185
92- type BackwardsCompatibleArgs =
93- | [ options : ExecutionArgs ]
94- | [
95- schema : ExecutionArgs [ 'schema' ] ,
96- document : ExecutionArgs [ 'document' ] ,
97- rootValue ?: ExecutionArgs [ 'rootValue' ] ,
98- contextValue ?: ExecutionArgs [ 'contextValue' ] ,
99- variableValues ?: ExecutionArgs [ 'variableValues' ] ,
100- operationName ?: ExecutionArgs [ 'operationName' ] ,
101- subscribeFieldResolver ?: ExecutionArgs [ 'subscribeFieldResolver' ] ,
102- ] ;
103-
104- function toNormalizedArgs ( args : BackwardsCompatibleArgs ) : ExecutionArgs {
105- const firstArg = args [ 0 ] ;
106- if ( 'document' in firstArg ) {
107- return firstArg ;
108- }
109-
110- return {
111- schema : firstArg ,
112- // FIXME: when underlying TS bug fixed, see https://github.com/microsoft/TypeScript/issues/31613
113- document : args [ 1 ] as DocumentNode ,
114- rootValue : args [ 2 ] ,
115- contextValue : args [ 3 ] ,
116- variableValues : args [ 4 ] ,
117- operationName : args [ 5 ] ,
118- subscribeFieldResolver : args [ 6 ] ,
119- } ;
120- }
121-
12286/**
12387 * Implements the "CreateSourceEventStream" algorithm described in the
12488 * GraphQL specification, resolving the subscription source event stream.
@@ -149,18 +113,7 @@ function toNormalizedArgs(args: BackwardsCompatibleArgs): ExecutionArgs {
149113 */
150114export function createSourceEventStream (
151115 args : ExecutionArgs ,
152- ) : PromiseOrValue < AsyncIterable < unknown > | ExecutionResult > ;
153- /** @deprecated will be removed in next major version in favor of named arguments */
154- export function createSourceEventStream (
155- schema : GraphQLSchema ,
156- document : DocumentNode ,
157- rootValue ?: unknown ,
158- contextValue ?: unknown ,
159- variableValues ?: Maybe < { readonly [ variable : string ] : unknown } > ,
160- operationName ?: Maybe < string > ,
161- subscribeFieldResolver ?: Maybe < GraphQLFieldResolver < any , any > > ,
162- ) : PromiseOrValue < AsyncIterable < unknown > | ExecutionResult > ;
163- export function createSourceEventStream ( ...rawArgs : BackwardsCompatibleArgs ) {
116+ ) : PromiseOrValue < AsyncIterable < unknown > | ExecutionResult > {
164117 const {
165118 schema,
166119 document,
@@ -169,7 +122,7 @@ export function createSourceEventStream(...rawArgs: BackwardsCompatibleArgs) {
169122 variableValues,
170123 operationName,
171124 subscribeFieldResolver,
172- } = toNormalizedArgs ( rawArgs ) ;
125+ } = args ;
173126
174127 // If arguments are missing or incorrectly typed, this is an internal
175128 // developer mistake which should throw an early error.
0 commit comments