Skip to content

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

@tcleonard

Description

@tcleonard
  • 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
            )

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions