Skip to content
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

relay.NodeField does not propagate arguments to Field #1035

Closed
tdiam opened this issue Jul 16, 2019 · 3 comments · Fixed by #1036
Closed

relay.NodeField does not propagate arguments to Field #1035

tdiam opened this issue Jul 16, 2019 · 3 comments · Fixed by #1036

Comments

@tdiam
Copy link
Contributor

tdiam commented Jul 16, 2019

The current implementation of NodeField's constructor does not propagate name, deprecation_reason or **kwargs to its parent Field constructor.
This would be useful, for example, when the field has a name that is reserved in Python:

klass = Node.Field(name='class', ...)

Is this expected behavior or is a fix needed?

Test code
from graphene import Node, ObjectType, Schema, String

droids = {1: {'name': 'R2-D2'}}

class DroidNode(ObjectType):
    class Meta:
        interfaces = (Node,)

    name = String()

    @classmethod
    def get_node(cls, info, id):
        return DroidNode(**droids[id])

class Query(ObjectType):
    droid = Node.Field(DroidNode, name='robot')

schema = Schema(query=Query)


def test_field_name_is_robot():
    r = schema.execute(
        """
        {
            __type(name: "Query") {
                fields { name }
            }
        }
        """
    )
    assert r.data['__type']['fields'][0]['name'] == 'robot'
@chason
Copy link

chason commented Jul 18, 2019

I am currently running into this issue passing description to the constructor so that the automatically generated documentation in GraphiQL says something besides "The ID of the object".

@stale
Copy link

stale bot commented Sep 16, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 16, 2019
@mattaustin
Copy link

I don't believe this issue to be stale. I am encountering the same problem today, and it would be great to see the related pull request merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants