3 ms·
Yeah I think that is what I mean. I want one class attribute to be a function of another class attribute. This may be naive but here is an example of what I w
by dwiel 11y ago
Yeah I think that is what I mean. I want one class attribute to be a function of another class attribute. This may be naive but here is an example of what I want to be able to do:
class User(graphene.ObjectType):
name = graphene.String()
initials = graphene.String()
def resolve_name(self, args, info):
return user_service.lookup_name(...)
def resolve_initials(self, args, info):
# How can I refer to the result of resolve_name above?
return ''.join(part for part in name.split(' '))
Perhaps I'm not using graphene in the way it was intended to be used?
- syrusakbary 11y agoUsually you have a self._root object (in Django, for example this _root is the model instance) and then you use self.instance.name in both resolve_name and resolve_initials.