I have a problem, where I want to optimise a client call to a mutation in a GraphQL API. The mutation executes 2 methods, where one is slow and where the result does not need to be send back to the client. I have tried to look at Django signals to handle this, but since signals are executed in sync, there is no benefit. Also, using Django signal request_finished seems not possible, because the method I need to execute needs to access model instance.
So my question is this.
Lets say I have a Django Model and I have two methods I use in a mutation.
class My_model(models.Model):
some_field = models.CharField()
def some_method():
return "do something"
def some_other_method():
return "do something else"
Now I have a mutation like the one below, where I do not want the client to wait for the execution of the method My_model.some_other_method()
class CreateTwoObjects(graphene.Mutation):
result = graphene.String()
def mutate(self, info, input):
result = My_model.some_method()
# method to not wait for
My_model.some_other_method()
return CreateTwoObjects(result = result)
Is there a way I can execute this method in async and not have client wait for the return?