Skip to content

Commit 712fad6

Browse files
Add back support for PromiseLike values in mutation resolvers (#365)
Partial revert of #364
1 parent 3cb8324 commit 712fad6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/mutation/mutation.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function mutationWithClientMutationId(
8888
resolve: (_, { input }, context, info) => {
8989
const { clientMutationId } = input;
9090
const payload = mutateAndGetPayload(input, context, info);
91-
if (payload instanceof Promise) {
91+
if (isPromiseLike(payload)) {
9292
return payload.then(injectClientMutationId);
9393
}
9494
return injectClientMutationId(payload);
@@ -104,3 +104,13 @@ export function mutationWithClientMutationId(
104104
},
105105
};
106106
}
107+
108+
// FIXME: Temporary until graphql-js resolves this issue
109+
// See, https://github.com/graphql/graphql-js/pull/3243#issuecomment-919510590
110+
declare function isPromiseLike(value: mixed): boolean %checks(value instanceof
111+
Promise);
112+
113+
// eslint-disable-next-line no-redeclare
114+
function isPromiseLike(value) {
115+
return typeof value?.then === 'function';
116+
}

0 commit comments

Comments
 (0)