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?
After investigating many days about how to make this done, I will write some solutions that may help.
fetch
inside resolver to your own API.next/after
, it has been produced in NextJS 15 RC (Beta).