Skip to content

Commit da8fe62

Browse files
committed
Follow up to #883
1 parent 508aa3a commit da8fe62

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

src/execution/__tests__/executor-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ describe('Execute: Handles basic execution tasks', () => {
637637
});
638638
});
639639

640-
it('throws if no op name is provided with multiple operations', async () => {
640+
it('errors if no op name is provided with multiple operations', async () => {
641641
const doc = 'query Example { a } query OtherExample { a }';
642642
const data = { a: 'b' };
643643
const ast = parse(doc);
@@ -663,7 +663,7 @@ describe('Execute: Handles basic execution tasks', () => {
663663
});
664664
});
665665

666-
it('throws if unknown operation name is provided', async () => {
666+
it('errors if unknown operation name is provided', async () => {
667667
const doc = 'query Example { a } query OtherExample { a }';
668668
const ast = parse(doc);
669669
const schema = new GraphQLSchema({

src/execution/execute.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ export function execute(
154154
/* eslint-enable no-param-reassign, no-redeclare */
155155
}
156156

157-
// If a valid context cannot be created due to incorrect arguments,
158-
// this will throw an error.
157+
// If arguments are missing or incorrect, throw an error.
159158
assertValidExecutionArguments(
160159
schema,
161160
document,
@@ -259,22 +258,6 @@ export function buildExecutionContext(
259258
operationName: ?string,
260259
fieldResolver: ?GraphQLFieldResolver<any, any>
261260
): ExecutionContext {
262-
invariant(schema, 'Must provide schema');
263-
invariant(document, 'Must provide document');
264-
invariant(
265-
schema instanceof GraphQLSchema,
266-
'Schema must be an instance of GraphQLSchema. Also ensure that there are ' +
267-
'not multiple versions of GraphQL installed in your node_modules directory.'
268-
);
269-
270-
// Variables, if provided, must be an object.
271-
invariant(
272-
!rawVariableValues || typeof rawVariableValues === 'object',
273-
'Variables must be provided as an Object where each property is a ' +
274-
'variable value. Perhaps look to see if an unparsed JSON string ' +
275-
'was provided.'
276-
);
277-
278261
const errors: Array<GraphQLError> = [];
279262
let operation: ?OperationDefinitionNode;
280263
const fragments: {[name: string]: FragmentDefinitionNode} =

src/subscription/subscribe.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import { isAsyncIterable } from 'iterall';
1313
import {
1414
addPath,
15+
assertValidExecutionArguments,
1516
buildExecutionContext,
1617
collectFields,
1718
execute,
@@ -137,6 +138,13 @@ export function createSourceEventStream(
137138
operationName?: ?string,
138139
fieldResolver?: ?GraphQLFieldResolver<any, any>
139140
): AsyncIterable<mixed> {
141+
// If arguments are missing or incorrect, throw an error.
142+
assertValidExecutionArguments(
143+
schema,
144+
document,
145+
variableValues
146+
);
147+
140148
// If a valid context cannot be created due to incorrect arguments,
141149
// this will throw an error.
142150
const exeContext = buildExecutionContext(

0 commit comments

Comments
 (0)