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

Connection and Edge types don't respect the name option of their respective Node #1011

Closed
tcleonard opened this issue Jul 27, 2020 · 0 comments
Labels

Comments

@tcleonard
Copy link
Collaborator

  • What is the current behavior?
    When setting up a node with a name specified using the name option in the Meta class the type of the Connection and Edge type associated still use the Node class name as base name.

For example if you do:

# cookbook/graphql/category.py
import graphene

from cookbook.models import Category, Ingredient


class CategoryNode(DjangoObjectType):
    class Meta:
        model = Category
        interfaces = (graphene.relay.Node, )
        name = "Category"


class Query(graphene.ObjectType):
    category = graphene.relay.Node.Field(CategoryNode)
    all_categories = DjangoFilterConnectionField(CategoryNode)

The exposed types will be Category, CategoryNodeConnection and CategoryNodeEdge.

  • What is the expected behavior?
    I would have expected that the types would be: Category, CategoryConnection and CategoryEdge.

  • Environment:

    • Version: graphene-django=2.12.1
    • Platform: all
  • Other information

This is due to this line which should be instead:

            connection = connection_class.create_type(
                "{}Connection".format(options.get("name") or cls.__name__), node=cls
            )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants