Skip to content

Commit c39e0f3

Browse files
committed
Remove unnecessary invariant in favor of explicit cast
See open TS issue microsoft/TypeScript#31613 Marked with FIXME for when TS feature/bug fix lands upstream [This code will likely be removed in v17 prior to the feature landing, but may be retained within v16 for longer.] Similar code "works" at https://github.com/graphql/graphql-js/blob/1f8ba95c662118452bd969c6b26ba4e9050c55da/src/error/GraphQLError.ts#L47 because all the option properties are optional.
1 parent 120ae79 commit c39e0f3

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/execution/subscribe.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { inspect } from '../jsutils/inspect';
2-
import { invariant } from '../jsutils/invariant';
32
import { isAsyncIterable } from '../jsutils/isAsyncIterable';
43
import { isPromise } from '../jsutils/isPromise';
54
import type { Maybe } from '../jsutils/Maybe';
@@ -108,11 +107,10 @@ function toNormalizedArgs(args: BackwardsCompatibleArgs): ExecutionArgs {
108107
return firstArg;
109108
}
110109

111-
invariant(args[1] != null, 'Must provide document.');
112-
113110
return {
114111
schema: firstArg,
115-
document: args[1],
112+
// FIXME: when underlying TS bug fixed, see https://github.com/microsoft/TypeScript/issues/31613
113+
document: args[1] as DocumentNode,
116114
rootValue: args[2],
117115
contextValue: args[3],
118116
variableValues: args[4],

0 commit comments

Comments
 (0)