Skip to content

Commit 05b3042

Browse files
authored
Merge pull request #7 from mirumee/fix-args-for-fields
Add missing logic for fields_args, bump version to 0.5
2 parents f95a48f + 61afcd8 commit 05b3042

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGELOG
22

3+
## 0.5.0 (2022-07-03)
4+
5+
- Implement missing logic for `ObjectType.__fields_args__`
6+
7+
38
## 0.4.0 (2022-05-04)
49

510
- Split logic from `BaseType` into `DefinitionType` and `BindableType`.

Diff for: ariadne_graphql_modules/object_type.py

+6
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,9 @@ def __bind_to_schema__(cls, schema):
118118

119119
for field_name, field_resolver in cls.resolvers.items():
120120
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

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
long_description=README,
2828
long_description_content_type="text/markdown",
2929
license="BSD",
30-
version="0.4.0",
30+
version="0.5.0",
3131
url="https://github.com/mirumee/ariadne-graphql-modules",
3232
packages=["ariadne_graphql_modules"],
3333
include_package_data=True,

Diff for: tests/test_object_type.py

+12
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,15 @@ class QueryType(ObjectType):
345345
other: String!
346346
firstField: String!
347347
secondField: String!
348+
fieldWithArg(someArg: String): String!
348349
}
349350
"""
350351
__aliases__ = {
351352
"firstField": "first_field",
352353
"secondField": "second_field",
354+
"fieldWithArg": "field_with_arg",
353355
}
356+
__fields_args__ = {"fieldWithArg": {"someArg": "some_arg"}}
354357

355358
@staticmethod
356359
def resolve_other(*_):
@@ -360,6 +363,10 @@ def resolve_other(*_):
360363
def resolve_second_field(obj, *_):
361364
return "Obj: %s" % obj["secondField"]
362365

366+
@staticmethod
367+
def resolve_field_with_arg(*_, some_arg):
368+
return some_arg
369+
363370

364371
schema = make_executable_schema(QueryType)
365372

@@ -384,3 +391,8 @@ def test_object_resolves_field_with_aliased_default_resolver():
384391
def test_object_resolves_field_with_aliased_custom_resolver():
385392
result = graphql_sync(schema, "{ secondField }", root_value={"secondField": "Hey!"})
386393
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"

0 commit comments

Comments
 (0)