本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
runtime
库提供一些实用程序以控制或修改解析器和函数的运行时属性。
-
runtime.earlyReturn(obj?: unknown): never
-
调用该函数将停止执行当前的 AWS AppSync 函数或解析器(单位解析器或管道解析器),具体取决于当前上下文。将返回指定的对象以作为结果。
-
在 AWS AppSync 函数请求处理程序中调用时,会跳过数据源和响应处理程序,并调用下一个函数请求处理程序(如果这是最后一个 AWS AppSync 函数,则调用管道解析器响应处理程序)。
-
在 AWS 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 }
-