From 8a1dd98704ab28209917242ef91d7015c31cce8b Mon Sep 17 00:00:00 2001 From: Lee Byron Date: Thu, 5 May 2016 09:21:51 -0700 Subject: [PATCH] Revert "Remove all 'instanceof GraphQLSchema' checks" --- src/execution/execute.js | 5 +++++ src/utilities/extendSchema.js | 4 ++++ src/validation/validate.js | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/src/execution/execute.js b/src/execution/execute.js index ecf3cff3f2..29e9de0e97 100644 --- a/src/execution/execute.js +++ b/src/execution/execute.js @@ -117,6 +117,11 @@ export function execute( operationName?: ?string ): Promise { invariant(schema, 'Must provide schema'); + 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.' + ); // If a valid context cannot be created due to incorrect arguments, // this will throw an error. diff --git a/src/utilities/extendSchema.js b/src/utilities/extendSchema.js index 2b2b9db7aa..2a7f57a75d 100644 --- a/src/utilities/extendSchema.js +++ b/src/utilities/extendSchema.js @@ -94,6 +94,10 @@ export function extendSchema( schema: GraphQLSchema, documentAST: Document ): GraphQLSchema { + invariant( + schema instanceof GraphQLSchema, + 'Must provide valid GraphQLSchema' + ); invariant( documentAST && documentAST.kind === DOCUMENT, diff --git a/src/validation/validate.js b/src/validation/validate.js index e22ffbf46e..b601e79042 100644 --- a/src/validation/validate.js +++ b/src/validation/validate.js @@ -53,6 +53,11 @@ export function validate( ): Array { invariant(schema, 'Must provide schema'); invariant(ast, '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.' + ); const typeInfo = new TypeInfo(schema); return visitUsingRules(schema, typeInfo, ast, rules || specifiedRules); }