Skip to content

Commit

Permalink
Add document validation to delegateToSchema (#551)
Browse files Browse the repository at this point in the history
* Add document validation to `delegateToSchema`
  • Loading branch information
schickling authored and freiksenet committed Jan 2, 2018
1 parent 59592e1 commit f2905ac
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/stitching/delegateToSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
execute,
visit,
subscribe,
validate,
} from 'graphql';
import { checkResultAndHandleErrors } from './errors';

Expand Down Expand Up @@ -59,6 +60,11 @@ export default async function delegateToSchema(
info.operation.variableDefinitions,
);

const errors = validate(schema, graphqlDoc);
if (errors.length > 0) {
throw errors;
}

const operationDefinition = graphqlDoc.definitions.find(
({ kind }) => kind === Kind.OPERATION_DEFINITION,
);
Expand Down

0 comments on commit f2905ac

Please sign in to comment.