Using Json Model Field With Django Graphene
I'm working with graphql endpoint for my project. One of models has textfield which contains some json. If i request list of my entities via graphql, I'm getting this json like a s
Solution 1:
You can declare resolver for data field with a custom type, e.g.
import graphene
from graphene.django.types import DjangoObjectType
classSysObjectsType(DjangoObjectType):
data = DataType()
classMeta:
model = SysObjects
defresolve_data(self, info):
# What you return here depends on how you are unpacking the JSON datareturn self.data
classDataType(graphene.ObjectType):
# What you put here depends on how you want to structure the JSON output
...
You might be able to extend this idea for DataType data to return DataType data, and thus be able to handle arbitrarily deep trees of data.
Post a Comment for "Using Json Model Field With Django Graphene"