-
I've been struggling with this for a few days and can't seem to find out how to do this properly in Ariadne. Anything with I want a resolver for a mutation However, this pull can take hours and shouldn't block the request / resolver. How do I asynchrously start that job, confirm that it's started with the user - but keep it running in the background. The job stores the result on the server which can in turn be queried later through a query. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You need to use separate worker handling the tasks queue like this (eg. Celery). Trying to solve this with just async/await in mutation is too little (what about handling errors/acknowledging result/retrying on failure?) and in wrong place (you will spend HTTP connection pool and resources on extra tasks not required for HTTP responses). |
Beta Was this translation helpful? Give feedback.
You need to use separate worker handling the tasks queue like this (eg. Celery). Trying to solve this with just async/await in mutation is too little (what about handling errors/acknowledging result/retrying on failure?) and in wrong place (you will spend HTTP connection pool and resources on extra tasks not required for HTTP responses).