Skip to content

Commit c80e36d

Browse files
Use "isPromise" instead of testing for 'then' property (#1879)
1 parent 4502ab9 commit c80e36d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/graphql.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @flow strict
88
*/
99

10+
import isPromise from './jsutils/isPromise';
1011
import { validateSchema } from './type/validate';
1112
import { parse } from './language/parser';
1213
import { validate } from './validation/validate';
@@ -175,7 +176,7 @@ export function graphqlSync(
175176
);
176177

177178
// Assert that the execution was synchronous.
178-
if (result.then) {
179+
if (isPromise(result)) {
179180
throw new Error('GraphQL execution failed to complete synchronously.');
180181
}
181182

src/utilities/introspectionFromSchema.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
import invariant from '../jsutils/invariant';
11+
import isPromise from '../jsutils/isPromise';
1112
import { type GraphQLSchema } from '../type/schema';
1213
import { execute } from '../execution/execute';
1314
import { parse } from '../language/parser';
@@ -32,6 +33,6 @@ export function introspectionFromSchema(
3233
): IntrospectionQuery {
3334
const queryAST = parse(getIntrospectionQuery(options));
3435
const result = execute(schema, queryAST);
35-
invariant(!result.then && !result.errors && result.data);
36+
invariant(!isPromise(result) && !result.errors && result.data);
3637
return (result.data: any);
3738
}

0 commit comments

Comments
 (0)