

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 執行期公用程式
<a name="runtime-utils-js"></a>

`runtime` 程式庫提供公用程式來控制或修改解析程式和函數的執行期屬性。

## 執行期 utils 清單
<a name="runtime-utils-list-js"></a>

 **`runtime.earlyReturn(obj?: unknown, returnOptions?: {skipTo: 'END' | 'NEXT'}): never`**  
根據目前的內容，叫用此函數會停止執行目前的處理常式、 AWS AppSync 函數或解析程式 （單位或管道解析程式）。系統會傳回指定的物件做為結果。  
+ 在 AWS AppSync 函數請求處理常式中呼叫 時，會略過資料來源和回應處理常式，並呼叫下一個函數請求處理常式 （如果這是最後一個 AWS AppSync 函數，則為管道解析程式回應處理常式）。
+ 在 AWS AppSync 管道解析程式請求處理常式中呼叫 時，會略過管道執行，並立即呼叫管道解析程式回應處理常式。
+ `returnOptions` 將 `skipTo` 設為 "END" 時，會略過管道執行，並立即呼叫管道解析程式回應處理常式。
+ `returnOptions` 將 `skipTo` 設為 "NEXT" 時，會略過函數執行，並呼叫下一個管道處理常式。
**範例**  

```
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
}
```