On this page

Execution Cancellation

In the real world, a lot of HTTP requests are dropped or canceled. This can happen due to a flakey internet connection, navigation to a new view or page within a web or native app or the user simply closing the app. In this case, the server can stop processing the request and save resources.

That is why Hive Gateway comes with the support for canceling the GraphQL execution upon request cancellation.

So any extra calls to the services can be stopped and the resources can be saved.

Execution Cancellation Is Enabled by Default

Execution cancellation is enabled by default, so you immediately benefit from it without making any other adjustments within your GraphQL schema implementation.

Disable Execution Cancellation

If you want to keep executing operations even after the client went away, you can disable it:

gateway.config.ts
import { defineConfig } from "@graphql-hive/gateway";

export const gatewayConfig = defineConfig({
  executionCancellation: false,
});

If you want to understand how it works and how you can adjust your resolvers to properly cancel pending promises (e.g. database reads or HTTP requests), you can continue with the next section.