Skip to content

Commit 7c7876d

Browse files
tdiamjkimbo
authored andcommitted
Propagate arguments of relay.NodeField to Field (#1036)
* Propagate name, deprecation_reason arguments of relay.NodeField to Field * Allow custom description in Node.Field and move ID description to ID argument * Add test for Node.Field with custom name * Add tests for description, deprecation_reason arguments of NodeField * Pass all kwargs from NodeField to Field
1 parent a3b215d commit 7c7876d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

graphene/relay/node.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def get_resolver(self, parent_resolver):
4747

4848

4949
class NodeField(Field):
50-
def __init__(self, node, type=False, deprecation_reason=None, name=None, **kwargs):
50+
def __init__(self, node, type=False, **kwargs):
5151
assert issubclass(node, Node), "NodeField can only operate in Nodes"
5252
self.node_type = node
5353
self.field_type = type
@@ -56,8 +56,8 @@ def __init__(self, node, type=False, deprecation_reason=None, name=None, **kwarg
5656
# If we don's specify a type, the field type will be the node
5757
# interface
5858
type or node,
59-
description="The ID of the object",
60-
id=ID(required=True),
59+
id=ID(required=True, description="The ID of the object"),
60+
**kwargs
6161
)
6262

6363
def get_resolver(self, parent_resolver):

graphene/relay/tests/test_node.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ def test_node_field_custom():
106106
assert node_field.node_type == Node
107107

108108

109+
def test_node_field_args():
110+
field_args = {
111+
"name": "my_custom_name",
112+
"description": "my_custom_description",
113+
"deprecation_reason": "my_custom_deprecation_reason",
114+
}
115+
node_field = Node.Field(**field_args)
116+
for field_arg, value in field_args.items():
117+
assert getattr(node_field, field_arg) == value
118+
119+
109120
def test_node_field_only_type():
110121
executed = schema.execute(
111122
'{ onlyNode(id:"%s") { __typename, name } } ' % Node.to_global_id("MyNode", 1)

0 commit comments

Comments
 (0)