Skip to content

Including id field in query aborts "only" optimization #2

@maarcingebala

Description

@maarcingebala

In my API I have a type which is based on Django's model using DjangoObjectType and relay.Node interface. Using the latter automatically adds the id (graphene.ID) field in the type.

class Product(DjangoObjectType):
    name = graphene.String()

    class Meta:
        interfaces = [relay.Node]
        model = models.Product

Now, when I query the API (with optimizer enabled) and include the id field in the query, the "only optimization" is aborted as a result of this check - my automatically added id field has no name. As a result, this function is called which sets the only_list to None and disables any future "only optimizations" I'd have in my case.

@tfoxy Could you validate the issue? Maybe I broke something on my side, but maybe it is a bug in the library.

Also, I don't fully understand why do you abort the optimization and set None to the only_list. I experimented with the code and assigned [] instead of None in that function and it solved the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions