|
1 | 1 | import { inspect } from '../jsutils/inspect'; |
2 | 2 | import { isAsyncIterable } from '../jsutils/isAsyncIterable'; |
3 | 3 | import { isPromise } from '../jsutils/isPromise'; |
4 | | -import type { Maybe } from '../jsutils/Maybe'; |
5 | 4 | import { addPath, pathToArray } from '../jsutils/Path'; |
6 | 5 | import type { PromiseOrValue } from '../jsutils/PromiseOrValue'; |
7 | 6 |
|
8 | 7 | import { GraphQLError } from '../error/GraphQLError'; |
9 | 8 | import { locatedError } from '../error/locatedError'; |
10 | 9 |
|
11 | | -import type { DocumentNode } from '../language/ast'; |
12 | | - |
13 | | -import type { GraphQLFieldResolver } from '../type/definition'; |
14 | | -import type { GraphQLSchema } from '../type/schema'; |
15 | | - |
16 | 10 | import { collectFields } from './collectFields'; |
17 | 11 | import type { |
18 | 12 | ExecutionArgs, |
@@ -89,36 +83,6 @@ function mapSourceToResponse( |
89 | 83 | ); |
90 | 84 | } |
91 | 85 |
|
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 (firstArg && '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 | | - |
122 | 86 | /** |
123 | 87 | * Implements the "CreateSourceEventStream" algorithm described in the |
124 | 88 | * GraphQL specification, resolving the subscription source event stream. |
@@ -149,22 +113,7 @@ function toNormalizedArgs(args: BackwardsCompatibleArgs): ExecutionArgs { |
149 | 113 | */ |
150 | 114 | export function createSourceEventStream( |
151 | 115 | 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( |
164 | | - ...rawArgs: BackwardsCompatibleArgs |
165 | 116 | ): PromiseOrValue<AsyncIterable<unknown> | ExecutionResult> { |
166 | | - const args = toNormalizedArgs(rawArgs); |
167 | | - |
168 | 117 | const { schema, document, variableValues } = args; |
169 | 118 |
|
170 | 119 | // If arguments are missing or incorrectly typed, this is an internal |
|
0 commit comments