File tree Expand file tree Collapse file tree 2 files changed +48
-3
lines changed Expand file tree Collapse file tree 2 files changed +48
-3
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,53 @@ describe('mutationWithClientMutationId()', () => {
147
147
} ) ;
148
148
} ) ;
149
149
150
+ /* FIXME fail because of this https://github.com/graphql/graphql-js/pull/3243#issuecomment-919510590
151
+ it.only('JS specific: handles `then` as field name', async () => {
152
+ const someMutation = mutationWithClientMutationId({
153
+ name: 'SomeMutation',
154
+ inputFields: {},
155
+ outputFields: {
156
+ result: {
157
+ type: new GraphQLObjectType({
158
+ name: 'Payload',
159
+ fields: {
160
+ then: { type: GraphQLString },
161
+ },
162
+ }),
163
+ },
164
+ },
165
+ mutateAndGetPayload() {
166
+ return {
167
+ then() {
168
+ return new Date(0);
169
+ }
170
+ };
171
+ },
172
+ });
173
+ const schema = wrapInSchema({ someMutation });
174
+
175
+ const source = `
176
+ mutation {
177
+ someMutation(input: {clientMutationId: "abc"}) {
178
+ clientMutationId
179
+ result { then }
180
+ }
181
+ }
182
+ `;
183
+
184
+ expect(await graphql({ schema, source })).to.deep.equal({
185
+ data: {
186
+ someMutation: {
187
+ clientMutationId: 'abc',
188
+ result: {
189
+ then: '',
190
+ },
191
+ },
192
+ },
193
+ });
194
+ });
195
+ */
196
+
150
197
it ( 'can access rootValue' , ( ) => {
151
198
const someMutation = mutationWithClientMutationId ( {
152
199
name : 'SomeMutation' ,
Original file line number Diff line number Diff line change @@ -13,8 +13,6 @@ import type {
13
13
Thunk ,
14
14
} from 'graphql' ;
15
15
16
- import isPromise from 'graphql/jsutils/isPromise' ;
17
-
18
16
type MutationFn = ( object : any , ctx : any , info : GraphQLResolveInfo ) => mixed ;
19
17
20
18
function resolveMaybeThunk < T > (thingOrThunk: Thunk< T > ): T {
@@ -90,7 +88,7 @@ export function mutationWithClientMutationId(
90
88
resolve : ( _ , { input } , context , info ) => {
91
89
const { clientMutationId } = input ;
92
90
const payload = mutateAndGetPayload ( input , context , info ) ;
93
- if ( isPromise ( payload ) ) {
91
+ if ( payload instanceof Promise ) {
94
92
return payload . then ( injectClientMutationId ) ;
95
93
}
96
94
return injectClientMutationId ( payload ) ;
You can’t perform that action at this time.
0 commit comments