

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

# 函式
<a name="sam-property-graphqlapi-function"></a>

在 GraphQL APIs中設定函數以執行特定操作。

## 語法
<a name="sam-property-graphqlapi-function-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

### YAML
<a name="sam-property-graphqlapi-function-syntax-yaml"></a>

```
LogicalId:
  CodeUri: String
  DataSource: String
  Description: String
  Id: String
  InlineCode: String
  MaxBatchSize: Integer
  Name: String
  Runtime: Runtime
  Sync: [SyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-functionconfiguration-syncconfig.html)
```

## Properties
<a name="sam-property-graphqlapi-function-properties"></a>

`CodeUri`  <a name="sam-graphqlapi-function-codeuri"></a>
函數程式碼的 Amazon Simple Storage Service (Amazon S3) URI 或本機資料夾的路徑。  
如果您指定本機資料夾的路徑， CloudFormation 需要先將檔案上傳至 Amazon S3，才能部署。您可以使用 AWS SAM CLI來促進此程序。如需詳細資訊，請參閱[如何在部署時 AWS SAM 上傳本機檔案](deploy-upload-local-files.md)。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[CodeS3Location](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-codes3location)` 屬性。

`DataSource`  <a name="sam-graphqlapi-function-datasource"></a>
此函數將連接的資料來源名稱。  
+ 若要參考`AWS::Serverless::GraphQLApi`資源中的資料來源，請指定其邏輯 ID。
+ 若要參考`AWS::Serverless::GraphQLApi`資源外部的資料來源，請使用 `Fn::GetAtt` 內部函數提供其`Name`屬性。例如 `!GetAtt MyLambdaDataSource.Name`。
+ 若要參考來自不同堆疊的資料來源，請使用 `[Fn::ImportValue](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html)`。
如果指定 的變化， `[NONE | None | none]` AWS SAM 將產生 `AWS::AppSync::DataSource` `[Type](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-datasource.html#cfn-appsync-datasource-type)` 物件`None`的值。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[DataSourceName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-datasourcename)` 屬性。

`Description`  <a name="sam-graphqlapi-function-description"></a>
函數的描述。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-description)` 屬性。

`Id`  <a name="sam-graphqlapi-function-id"></a>
位於`AWS::Serverless::GraphQLApi`資源外部之函數的函數 ID。  
+ 若要在相同 AWS SAM 範本中參考函數，請使用 `Fn::GetAtt` 內部函數。例如 `Id: !GetAtt createPostItemFunc.FunctionId`。
+ 若要參考來自不同堆疊的函數，請使用 `[Fn::ImportValue](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html)`。
使用 時`Id`，不允許所有其他屬性。 AWS SAM 會自動傳遞參考函數的函數 ID。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

`InlineCode`  <a name="sam-graphqlapi-function-inlinecode"></a>
包含請求和回應函數的函數程式碼。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[Code](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-code)` 屬性。

`LogicalId`  <a name="sam-graphqlapi-function-logicalid"></a>
函數的唯一名稱。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-name)` 屬性。

`MaxBatchSize`  <a name="sam-graphqlapi-function-maxbatchsize"></a>
解析程式請求輸入的數量上限，輸入將傳送到 `BatchInvoke` 操作中的單一 AWS Lambda 函數。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 [MaxBatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-maxbatchsize) 屬性。

`Name`  <a name="sam-graphqlapi-function-name"></a>
函數的名稱。指定 以覆寫 `LogicalId`值。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-name)` 屬性。

`Runtime`  <a name="sam-graphqlapi-function-runtime"></a>
描述 AWS AppSync 管道解析程式或 AWS AppSync 函數使用的執行時間。指定要使用的執行階段名稱和版本。  
*類型*：[執行期](sam-property-graphqlapi-function-runtime.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。它類似於 `AWS::AppSync::FunctionConfiguration` 資源的 `[Runtime](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-runtime)` 屬性。

`Sync`  <a name="sam-graphqlapi-function-sync"></a>
描述函數的 Sync 組態。  
指定叫用函數時要使用的衝突偵測策略和解決策略。  
*類型*：[SyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-functionconfiguration-syncconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::AppSync::FunctionConfiguration` 資源的 `[SyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-syncconfig)` 屬性。

# 執行時期
<a name="sam-property-graphqlapi-function-runtime"></a>

管道解析程式或函數的執行時間。指定要使用的名稱和版本。

## 語法
<a name="sam-property-graphqlapi-function-runtime-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

### YAML
<a name="sam-property-graphqlapi-function-runtime-syntax-yaml"></a>

```
Name: String
Version: String
```

## Properties
<a name="sam-property-graphqlapi-function-runtime-properties"></a>

`Name`  <a name="sam-graphqlapi-function-runtime-name"></a>
要使用的執行時間名稱。目前，唯一允許的值為 `APPSYNC_JS`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::FunctionConfiguration AppSyncRuntime`物件的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-functionconfiguration-appsyncruntime.html#cfn-appsync-functionconfiguration-appsyncruntime-name)` 屬性。

`Version`  <a name="sam-graphqlapi-function-runtime-version"></a>
要使用的執行時間版本。目前唯一允許的版本為 `1.0.0`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至`AWS::AppSync::FunctionConfiguration AppSyncRuntime`物件的 `[RuntimeVersion](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-functionconfiguration-appsyncruntime.html#cfn-appsync-functionconfiguration-appsyncruntime-runtimeversion)` 屬性。