Keep running other functions after return in GraphQL resolvers

16 Views Asked by At

How can I keep other operation running after return in GraphQL resolvers.

packages

import { ApolloServer } from "@apollo/server";
import { typeDefs } from "./definitions";
import { resolvers } from "./resolvers";
import { makeExecutableSchema } from "graphql-tools";
import { applyMiddleware } from "graphql-middleware";
import { shield, allow } from "graphql-shield";
import { permissions } from "./shield/permissions";

Code

createOrder: async (_: any, args: MutationCreateOrderArgs, ctx: IContext) => {

const sendToGoogleSheetsPromise....
const sendToConversionApiPrmise....

return ctx.order.create()
}

Promises somehow got cancelled after return, I don't want to wait all of them or using Promise.all.

Is there something like waitUntil() in service workers?

0

There are 0 best solutions below