Skip to content

Propagate arguments of relay.NodeField to Field #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions graphene/relay/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get_resolver(self, parent_resolver):


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

def get_resolver(self, parent_resolver):
Expand Down
11 changes: 11 additions & 0 deletions graphene/relay/tests/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ def test_node_field_custom():
assert node_field.node_type == Node


def test_node_field_args():
field_args = {
"name": "my_custom_name",
"description": "my_custom_description",
"deprecation_reason": "my_custom_deprecation_reason",
}
node_field = Node.Field(**field_args)
for field_arg, value in field_args.items():
assert getattr(node_field, field_arg) == value


def test_node_field_only_type():
executed = schema.execute(
'{ onlyNode(id:"%s") { __typename, name } } ' % Node.to_global_id("MyNode", 1)
Expand Down