Skip to content

Commit

Permalink
Use "isPromise" instead of testing for 'then' property (#1879)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed May 21, 2019
1 parent 4502ab9 commit c80e36d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/graphql.js
Expand Up @@ -7,6 +7,7 @@
* @flow strict
*/

import isPromise from './jsutils/isPromise';
import { validateSchema } from './type/validate';
import { parse } from './language/parser';
import { validate } from './validation/validate';
Expand Down Expand Up @@ -175,7 +176,7 @@ export function graphqlSync(
);

// Assert that the execution was synchronous.
if (result.then) {
if (isPromise(result)) {
throw new Error('GraphQL execution failed to complete synchronously.');
}

Expand Down
3 changes: 2 additions & 1 deletion src/utilities/introspectionFromSchema.js
Expand Up @@ -8,6 +8,7 @@
*/

import invariant from '../jsutils/invariant';
import isPromise from '../jsutils/isPromise';
import { type GraphQLSchema } from '../type/schema';
import { execute } from '../execution/execute';
import { parse } from '../language/parser';
Expand All @@ -32,6 +33,6 @@ export function introspectionFromSchema(
): IntrospectionQuery {
const queryAST = parse(getIntrospectionQuery(options));
const result = execute(schema, queryAST);
invariant(!result.then && !result.errors && result.data);
invariant(!isPromise(result) && !result.errors && result.data);
return (result.data: any);
}

0 comments on commit c80e36d

Please sign in to comment.