Skip to content

Commit

Permalink
Fix test_builds_a_schema_with_field_arguments_with_default_values.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnak committed Dec 30, 2019
1 parent fa41da8 commit b8f5e05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions graphql/utils/build_client_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def build_input_object_def(input_object_introspection):
fields=lambda: build_input_value_def_map(
input_object_introspection.get("inputFields"), GraphQLInputObjectField
),
container_type=OrderedDict,
)

type_builders = {
Expand Down
11 changes: 8 additions & 3 deletions graphql/utils/value_from_ast.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ..language import ast
from ..pyutils.ordereddict import OrderedDict
from ..type import (
GraphQLEnumType,
GraphQLInputObjectType,
Expand Down Expand Up @@ -56,13 +57,15 @@ def value_from_ast(value_ast, type, variables=None):
for field_ast in value_ast.fields:
field_asts[field_ast.name.value] = field_ast

obj = {}
obj_items = []
for field_name, field in fields.items():
if field_name not in field_asts:
if field.default_value is not None:
# We use out_name as the output name for the
# dict if exists
obj[field.out_name or field_name] = field.default_value
obj_items.append(
(field.out_name or field_name, field.default_value)
)

continue

Expand All @@ -72,7 +75,9 @@ def value_from_ast(value_ast, type, variables=None):

# We use out_name as the output name for the
# dict if exists
obj[field.out_name or field_name] = field_value
obj_items.append((field.out_name or field_name, field_value))

obj = OrderedDict(obj_items)

return type.create_container(obj)

Expand Down

0 comments on commit b8f5e05

Please sign in to comment.