Skip to content

Commit afa44e8

Browse files
tcleonardtdiam
andauthored
Propagate arguments of relay.NodeField to Field (#1036) (#1307)
* 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 Co-authored-by: Theodore Diamantidis <[email protected]>
1 parent 3d0e460 commit afa44e8

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
@@ -48,7 +48,7 @@ def get_resolver(self, parent_resolver):
4848

4949

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

6464
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
@@ -110,6 +110,17 @@ def test_node_field_custom():
110110
assert node_field.node_type == Node
111111

112112

113+
def test_node_field_args():
114+
field_args = {
115+
"name": "my_custom_name",
116+
"description": "my_custom_description",
117+
"deprecation_reason": "my_custom_deprecation_reason",
118+
}
119+
node_field = Node.Field(**field_args)
120+
for field_arg, value in field_args.items():
121+
assert getattr(node_field, field_arg) == value
122+
123+
113124
def test_node_field_only_type():
114125
executed = schema.execute(
115126
'{ onlyNode(id:"%s") { __typename, name } } ' % Node.to_global_id("MyNode", 1)

0 commit comments

Comments
 (0)