运行时实用程序 - Amazon AppSync
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

运行时实用程序

runtime 库提供一些实用程序以控制或修改解析器和函数的运行时属性。

runtime.earlyReturn(obj?: unknown): never

调用该函数将停止执行当前的 Amazon AppSync 函数或解析器(单位解析器或管道解析器),具体取决于当前上下文。将返回指定的对象以作为结果。

  • 在 Amazon AppSync 函数请求处理程序中调用时,将跳过数据源和响应处理程序,并调用下一个函数请求处理程序(如果这是最后一个 Amazon AppSync 函数,则调用管道解析器响应处理程序)。

  • 在 Amazon AppSync 管道解析器请求处理程序中调用时,将跳过管道执行,并立即调用管道解析器响应处理程序。

示例

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 }