From c93387c139477f304168bb8a44d6a03cb95c24b6 Mon Sep 17 00:00:00 2001 From: Johannes Schickling Date: Thu, 21 Dec 2017 12:13:21 +0100 Subject: [PATCH 1/2] Add document validation to `delegateToSchema` --- src/stitching/delegateToSchema.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/stitching/delegateToSchema.ts b/src/stitching/delegateToSchema.ts index b60b0aa2594..11f9b1cb5cf 100644 --- a/src/stitching/delegateToSchema.ts +++ b/src/stitching/delegateToSchema.ts @@ -25,6 +25,7 @@ import { execute, visit, subscribe, + validate, } from 'graphql'; import { checkResultAndHandleErrors } from './errors'; @@ -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, ); From 3a5197da5eae394abbcb63ea5ccfe5c9f94a4a8f Mon Sep 17 00:00:00 2001 From: Johannes Schickling Date: Tue, 2 Jan 2018 13:13:19 +0100 Subject: [PATCH 2/2] fix: liniting errors --- src/stitching/delegateToSchema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stitching/delegateToSchema.ts b/src/stitching/delegateToSchema.ts index 11f9b1cb5cf..52c082a508c 100644 --- a/src/stitching/delegateToSchema.ts +++ b/src/stitching/delegateToSchema.ts @@ -64,7 +64,7 @@ export default async function delegateToSchema( if (errors.length > 0) { throw errors; } - + const operationDefinition = graphqlDoc.definitions.find( ({ kind }) => kind === Kind.OPERATION_DEFINITION, );