Skip to content

Commit

Permalink
Follow up to #883
Browse files Browse the repository at this point in the history
  • Loading branch information
leebyron committed May 26, 2017
1 parent 508aa3a commit da8fe62
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/execution/__tests__/executor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ describe('Execute: Handles basic execution tasks', () => {
});
});

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

it('throws if unknown operation name is provided', async () => {
it('errors if unknown operation name is provided', async () => {
const doc = 'query Example { a } query OtherExample { a }';
const ast = parse(doc);
const schema = new GraphQLSchema({
Expand Down
19 changes: 1 addition & 18 deletions src/execution/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ export function execute(
/* eslint-enable no-param-reassign, no-redeclare */
}

// If a valid context cannot be created due to incorrect arguments,
// this will throw an error.
// If arguments are missing or incorrect, throw an error.
assertValidExecutionArguments(
schema,
document,
Expand Down Expand Up @@ -259,22 +258,6 @@ export function buildExecutionContext(
operationName: ?string,
fieldResolver: ?GraphQLFieldResolver<any, any>
): ExecutionContext {
invariant(schema, 'Must provide schema');
invariant(document, 'Must provide document');
invariant(
schema instanceof GraphQLSchema,
'Schema must be an instance of GraphQLSchema. Also ensure that there are ' +
'not multiple versions of GraphQL installed in your node_modules directory.'
);

// Variables, if provided, must be an object.
invariant(
!rawVariableValues || typeof rawVariableValues === 'object',
'Variables must be provided as an Object where each property is a ' +
'variable value. Perhaps look to see if an unparsed JSON string ' +
'was provided.'
);

const errors: Array<GraphQLError> = [];
let operation: ?OperationDefinitionNode;
const fragments: {[name: string]: FragmentDefinitionNode} =
Expand Down
8 changes: 8 additions & 0 deletions src/subscription/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import { isAsyncIterable } from 'iterall';
import {
addPath,
assertValidExecutionArguments,
buildExecutionContext,
collectFields,
execute,
Expand Down Expand Up @@ -137,6 +138,13 @@ export function createSourceEventStream(
operationName?: ?string,
fieldResolver?: ?GraphQLFieldResolver<any, any>
): AsyncIterable<mixed> {
// If arguments are missing or incorrect, throw an error.
assertValidExecutionArguments(
schema,
document,
variableValues
);

// If a valid context cannot be created due to incorrect arguments,
// this will throw an error.
const exeContext = buildExecutionContext(
Expand Down

0 comments on commit da8fe62

Please sign in to comment.