Description
tl;dr: DjangoObjectType ignores all unknown values in Meta.fields
. It should compare the fields list with the available Model's fields instead.
I'm in the process of rewriting DRF-based backend to graphene-django, and I was surprised when my graphene-django generated schema was silently missing the fields I specified in fields
.
(I'm copy-pasting fields
from DRF serializers to DjangoObjectType's Meta class).
Turns out some of these fields were implemented as properties or methods on models, and I'm ok with writing custom resolvers for those (otherwise there's no way to detect types, at least in the absence of type hints), but I didn't expect DjangoObjectType to quietly accept unknown values.
I believe the reason for this is that graphene_django.types.construct_fields
iterates over model's fields, but it could/should iterate over only_fields
too.
Implementing the same check for exclude
also seems like a good idea to me (otherwise you could make a typo in exclude
, but never notice it until it's too late).