I have some problems when I try to query a Django charField with choices.
I have the following models.py :
class Vehicle(models.Model):
TYPE_CHOICES = (
('MOTO', _('MOTORBIKE')),
('CAR', _('car')),
('BIKE', _('bike')),
)
name = models.CharField(max_length=100)
vtype = models.CharField(
_('Vehicle type'),
max_length=5,
choices=TYPE_CHOICES,
default='MOTO',
help_text=_('Lorem ipsum')
)
description = models.TextField(blank=True, default='')
def __str__(self):
return self.name
and the following schema.py :
class VehicleNode(DjangoNode):
class Meta:
model = Vehicle
When I try to make this query :
query {
allVehicles {
edges {
node {
id,
name,
vtype
}
}
}
}
I have the following error :
{
"errors": [
{
"message": "Cannot query field \"vtype\" on type \"VehicleNode\".",
"locations": [
{
"line": 7,
"column": 9
}
]
}
]
}
To be able to query vtype I need to add vtype = String() into my schema like that :
class VehicleNode(DjangoNode):
vtype = String()
class Meta:
model = Vehicle
I don't know if I missed something ?
Does it work if you define everything as plain strings instead of using _('xxxxx')?
No, I have the same issue
I have the same issue here
Is this issue related to https://github.com/graphql-python/graphene/issues/290?
This should be fixed in graphene-django:master. Closing here :)
Most helpful comment
I have the same issue here