Hello I simply want to avoid repeating code for each query, and I was wondering if I could call a method from inside a resolver a such:
# pseudo code
class Query(graphene.ObjectType):
field = graphene.Field(SomeType)
def do_boring_task(parent, info, arg):
return "I did something"
def resolve_field(parent, info):
did_something = parent.do_boring_task(arg) # <-- is this possible ?
# do something here
return resolved_fields
I always get a "graphql.error.located_error.GraphQLLocatedError: 'NoneType' object has no attribute 'do_boring_task'" error
Is it possible to do that the way I described it, or is this something that should be done using middleware?
Thanks