Hi
I have a question. I cannot find any suitable example. Is there a possibility to add an extra field which will be returning data from particular method ? I mean I have a Node defined (node inherits from DjangoObjectType) and my model has some properties (method with @property decorator). I would like to be able to add this data into graphql response. I've tried with resolve_{name} method but there is no access to particular instance inside this method. Maybe I missed something.
Thanks, great project !
Hey, it's soo easy. I didn't notice that self in Node is just an object of our model.
So you need to only add field:
property = graphene.String()
and resolver:
def resolve_property(self, _args, *_kwargs):
return self.property
and it works like a charm.
Most helpful comment
Hey, it's soo easy. I didn't notice that self in Node is just an object of our model.
So you need to only add field:
property = graphene.String()
and resolver:
def resolve_property(self, _args, *_kwargs):
return self.property
and it works like a charm.