Skip to content

Django integer fields gets transformed to Float? #678

Closed
@crazyscientist

Description

@crazyscientist

On a project of mine I noticed this unexpected behavior:

Using graphene_django with graphene.relay converts IntegrierFields of my models to graphene.Float properties in the API, e.g.:

class Incident(models.Model):
    incident_id = models.IntegerField(unique=True)

class IncidentType(graphene_django.types.DjangoObjectType):
    class Meta:
        model = Incident
        interfaces = (graphene.relay.Node,)
        filter_fields = {
            'incident_id': ['exact'],
    }

class Query:
    incident = graphene.relay.Node.Field(IncidentType)
    incidents = DjangoFilterConnectionField(IncidentType)

To be precise, using the incident attribute shows the incidentId to be of type Int. But using the incidents attribute suggests that incidentId is of type Float.

I'd like to point out, that there is no error occurring, but it strikes me as weird.

I observed this with:

  • Django 2.2
  • django-filter 2.1.0
  • graphene 2.1.3
  • graphene-django 2.2.0
  • graphql-core 2.1
  • graphql-relay 0.4.5

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions