Skip to content

Resolve warning from ForeignKey in exclude statement (warnings added in 2.8.1.) #875

Closed
@lassesteffen

Description

@lassesteffen

Thanks for the awesome work team! Since 2.8.1 I get these warning from graphene_django (and many more which are similar, because I added same fields to the exclude tag

  1. My orders.Project model has a ForeignKey called tenant mapping to users.Tenant. I can access the Tenant in graphql direct from the project if I do not put it in the exclude (works even though the warning is there)
  warnings.warn(
/usr/local/lib/python3.8/site-packages/graphene_django/types.py:76: UserWarning: Field name "tenant" matches an attribute on Django model "orders.Project" but it's not a model field so Graphene cannot determine what type it should be. Either define the type of the field on DjangoObjectType "ProjectNode" or remove it from the "fields" list.
  1. Same situation as above. But this time other way around. Since I am using relay I could normally query the field by membership_set { edges { node { id} } } if not putting it in exclude. If adding it to exclude I get this warning.
  warnings.warn(
/usr/local/lib/python3.8/site-packages/graphene_django/types.py:76: UserWarning: Field name "project_set" matches an attribute on Django model "users.Tenant" but it's not a model field so Graphene cannot determine what type it should be. Either define the type of the field on DjangoObjectType "TenantNode" or remove it from the "fields" list.

Question: Is this intended? If yes how do can I resolve it? I have read through the PRs related to the latest version (I can definitely see where this error comes from), but am still clueless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions