@@ -154,7 +154,7 @@ def can_access_root_value():
154154 )
155155
156156 def supports_mutations_returning_null ():
157- def null_resolve (_info , ** _input ) -> None :
157+ def null_resolve (_info , ** _input ):
158158 return None
159159
160160 some_mutation = mutation_with_client_mutation_id (
@@ -176,7 +176,7 @@ def null_resolve(_info, **_input) -> None:
176176
177177 @mark .asyncio
178178 async def supports_async_mutations_returning_null ():
179- async def null_resolve (_info , ** _input ) -> None :
179+ async def null_resolve (_info , ** _input ):
180180 return None
181181
182182 some_mutation = mutation_with_client_mutation_id (
@@ -234,6 +234,61 @@ def resolve(cls, obj, _info):
234234 None ,
235235 )
236236
237+ def supports_mutations_returning_mappings ():
238+ def dict_mutate (_info , ** _input ):
239+ return {"some_data" : 1 }
240+
241+ def dict_resolve (obj , _info ):
242+ return obj ["some_data" ]
243+
244+ some_mutation = mutation_with_client_mutation_id (
245+ "SomeMutation" ,
246+ {},
247+ {"result" : GraphQLField (GraphQLInt , resolve = dict_resolve )},
248+ dict_mutate ,
249+ )
250+ schema = wrap_in_schema ({"someMutation" : some_mutation })
251+ source = """
252+ mutation {
253+ someMutation(input: {clientMutationId: "abc"}) {
254+ result
255+ clientMutationId
256+ }
257+ }
258+ """
259+ assert graphql_sync (schema , source ) == (
260+ {"someMutation" : {"result" : 1 , "clientMutationId" : "abc" }},
261+ None ,
262+ )
263+
264+ @mark .asyncio
265+ async def supports_async_mutations_returning_mappings ():
266+ async def dict_mutate (_info , ** _input ):
267+ return {"some_data" : 1 }
268+
269+ async def dict_resolve (obj , _info ):
270+ return obj ["some_data" ]
271+
272+ some_mutation = mutation_with_client_mutation_id (
273+ "SomeMutation" ,
274+ {},
275+ {"result" : GraphQLField (GraphQLInt , resolve = dict_resolve )},
276+ dict_mutate ,
277+ )
278+ schema = wrap_in_schema ({"someMutation" : some_mutation })
279+ source = """
280+ mutation {
281+ someMutation(input: {clientMutationId: "abc"}) {
282+ result
283+ clientMutationId
284+ }
285+ }
286+ """
287+ assert await graphql (schema , source ) == (
288+ {"someMutation" : {"result" : 1 , "clientMutationId" : "abc" }},
289+ None ,
290+ )
291+
237292 def generates_correct_types ():
238293 some_mutation = mutation_with_client_mutation_id (
239294 "SomeMutation" ,
0 commit comments