File tree 4 files changed +24
-1
lines changed
4 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 1
1
# CHANGELOG
2
2
3
+ ## 0.5.0 (2022-07-03)
4
+
5
+ - Implement missing logic for ` ObjectType.__fields_args__ `
6
+
7
+
3
8
## 0.4.0 (2022-05-04)
4
9
5
10
- Split logic from ` BaseType ` into ` DefinitionType ` and ` BindableType ` .
Original file line number Diff line number Diff line change @@ -118,3 +118,9 @@ def __bind_to_schema__(cls, schema):
118
118
119
119
for field_name , field_resolver in cls .resolvers .items ():
120
120
graphql_type .fields [field_name ].resolve = field_resolver
121
+
122
+ if cls .__fields_args__ :
123
+ for field_name , field_args_mappings in cls .__fields_args__ .items ():
124
+ field_args = graphql_type .fields [field_name ].args
125
+ for arg_name , arg_out_name in field_args_mappings .items ():
126
+ field_args [arg_name ].out_name = arg_out_name
Original file line number Diff line number Diff line change 27
27
long_description = README ,
28
28
long_description_content_type = "text/markdown" ,
29
29
license = "BSD" ,
30
- version = "0.4 .0" ,
30
+ version = "0.5 .0" ,
31
31
url = "https://github.com/mirumee/ariadne-graphql-modules" ,
32
32
packages = ["ariadne_graphql_modules" ],
33
33
include_package_data = True ,
Original file line number Diff line number Diff line change @@ -345,12 +345,15 @@ class QueryType(ObjectType):
345
345
other: String!
346
346
firstField: String!
347
347
secondField: String!
348
+ fieldWithArg(someArg: String): String!
348
349
}
349
350
"""
350
351
__aliases__ = {
351
352
"firstField" : "first_field" ,
352
353
"secondField" : "second_field" ,
354
+ "fieldWithArg" : "field_with_arg" ,
353
355
}
356
+ __fields_args__ = {"fieldWithArg" : {"someArg" : "some_arg" }}
354
357
355
358
@staticmethod
356
359
def resolve_other (* _ ):
@@ -360,6 +363,10 @@ def resolve_other(*_):
360
363
def resolve_second_field (obj , * _ ):
361
364
return "Obj: %s" % obj ["secondField" ]
362
365
366
+ @staticmethod
367
+ def resolve_field_with_arg (* _ , some_arg ):
368
+ return some_arg
369
+
363
370
364
371
schema = make_executable_schema (QueryType )
365
372
@@ -384,3 +391,8 @@ def test_object_resolves_field_with_aliased_default_resolver():
384
391
def test_object_resolves_field_with_aliased_custom_resolver ():
385
392
result = graphql_sync (schema , "{ secondField }" , root_value = {"secondField" : "Hey!" })
386
393
assert result .data ["secondField" ] == "Obj: Hey!"
394
+
395
+
396
+ def test_object_resolves_field_with_arg_out_name_customized ():
397
+ result = graphql_sync (schema , '{ fieldWithArg(someArg: "test") }' )
398
+ assert result .data ["fieldWithArg" ] == "test"
You can’t perform that action at this time.
0 commit comments