

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

# 函数
<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>
描述函数的同步配置。  
指定在调用函数时要使用的冲突检测策略和解决策略。  
*类型*：[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)`属性。