Skip to content

ManyToOneRel fields are wrongly named, causing the field resolver to return every single record. #63

Closed
@yen223

Description

@yen223

<This is on Django 1.8.16>

A foreign key on model Article to model Reporter will automatically create a reverse field called article_set on the Reporter model. However for some reason, the corresponding related field name does not contain the _set suffix:

>> Reporter.article_set.related.name
'article'

This causes the constructed field on the ReporterObjectType to be wrongly named article at https://github.com/graphql-python/graphene-django/blob/master/graphene_django/types.py#L25, which in turn causes the Reporter.article field to be unresolvable, as the Reporter instance lacks the article attribute.

That in turn causes https://github.com/graphql-python/graphene-django/blob/master/graphene_django/fields.py#L49 to default to the Article model's manager, which results in every Article instance being returned.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions