Runtime utilities - Amazon AppSync
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Runtime utilities

The runtime library provides utilities to control or modify the runtime properties of your resolvers and functions.

runtime.earlyReturn(obj?: unknown): never

Invoking this function will halt the execution of the current Amazon AppSync function or resolver (Unit or Pipeline Resolver) depending on the current context. The specified object is returned as the result.

  • When called in an Amazon AppSync function request handler, the data source and response handler are skipped, and the next function request handler (or the pipeline resolver response handler if this was the last Amazon AppSync function) is called.

  • When called in an Amazon AppSync pipeline resolver request handler, the pipeline execution is skipped, and the pipeline resolver response handler is called immediately.

Example

import { runtime } from '@aws-appsync/utils' export function request(ctx) { runtime.earlyReturn({ hello: 'world' }) // code below is not executed return ctx.args } // never called because request returned early export function response(ctx) { return ctx.result }