1๐
Iโm not sure of a simple way of doing it in graphene-django/python. It seems like there are ways to achieve this in NodeJS. However if your goal is to add some data to every single response, you can make a super class that all your classes inherit from. This means your extra_field
will always be there, but it will be inside data
.
class MyBaseType(DjangoObjectType):
class Meta:
abstract = True
extra_field = graphene.JSONField()
def resolve_extra_field(self, info):
return #something
And then inherit in your normal classes.
class UserType(MyBaseType):
class Meta:
model = User
๐คrymanso
Source:stackexchange.com