@@ -31,6 +31,21 @@ var simpleMutation = mutationWithClientMutationId({
31
31
mutateAndGetPayload : ( ) => ( { result : 1 } )
32
32
} ) ;
33
33
34
+ var simpleMutationWithThunkFields = mutationWithClientMutationId ( {
35
+ name : 'SimpleMutationWithThunkFields' ,
36
+ inputFields : ( ) => ( {
37
+ inputData : {
38
+ type : GraphQLInt
39
+ }
40
+ } ) ,
41
+ outputFields : ( ) => ( {
42
+ result : {
43
+ type : GraphQLInt
44
+ }
45
+ } ) ,
46
+ mutateAndGetPayload : ( { inputData } ) => ( { result : inputData } )
47
+ } ) ;
48
+
34
49
var simplePromiseMutation = mutationWithClientMutationId ( {
35
50
name : 'SimplePromiseMutation' ,
36
51
inputFields : { } ,
@@ -46,6 +61,7 @@ var mutation = new GraphQLObjectType({
46
61
name : 'Mutation' ,
47
62
fields : {
48
63
simpleMutation : simpleMutation ,
64
+ simpleMutationWithThunkFields : simpleMutationWithThunkFields ,
49
65
simplePromiseMutation : simplePromiseMutation
50
66
}
51
67
} ) ;
@@ -89,6 +105,26 @@ describe('mutationWithClientMutationId()', () => {
89
105
return expect ( graphql ( schema , query ) ) . to . become ( expected ) ;
90
106
} ) ;
91
107
108
+ it ( 'Supports thunks as input and output fields' , ( ) => {
109
+ var query = `
110
+ mutation M {
111
+ simpleMutationWithThunkFields(input: {inputData: 1234, clientMutationId: "abc"}) {
112
+ result
113
+ clientMutationId
114
+ }
115
+ }
116
+ ` ;
117
+ var expected = {
118
+ data : {
119
+ simpleMutationWithThunkFields : {
120
+ result : 1234 ,
121
+ clientMutationId : 'abc'
122
+ }
123
+ }
124
+ } ;
125
+ return expect ( graphql ( schema , query ) ) . to . become ( expected ) ;
126
+ } ) ;
127
+
92
128
it ( 'supports promise mutations' , ( ) => {
93
129
var query = `
94
130
mutation M {
@@ -249,6 +285,26 @@ describe('mutationWithClientMutationId()', () => {
249
285
kind : 'OBJECT' ,
250
286
}
251
287
} ,
288
+ {
289
+ name : 'simpleMutationWithThunkFields' ,
290
+ args : [
291
+ {
292
+ name : 'input' ,
293
+ type : {
294
+ name : null ,
295
+ kind : 'NON_NULL' ,
296
+ ofType : {
297
+ name : 'SimpleMutationWithThunkFieldsInput' ,
298
+ kind : 'INPUT_OBJECT'
299
+ }
300
+ } ,
301
+ }
302
+ ] ,
303
+ type : {
304
+ name : 'SimpleMutationWithThunkFieldsPayload' ,
305
+ kind : 'OBJECT' ,
306
+ }
307
+ } ,
252
308
{
253
309
name : 'simplePromiseMutation' ,
254
310
args : [
0 commit comments