AWS::AppSync::Resolver
AWS::AppSync::Resolver
资源定义您附加到架构中的字段的逻辑 GraphQL 解决程序。解决程序的请求和响应模板用 Apache Velocity 模板语言 (VTL) 格式编写。有关解决程序的更多信息,请参阅解决程序映射模板参考。
提交更新时,AWS CloudFormation 会基于提交的内容与堆栈的当前模板之间的差异来更新资源。要更新此资源,您必须在 CloudFormation 模板中更改此资源的属性值。在不更改属性值的情况下更改 S3 文件内容不会导致更新操作。
请参阅 AWS CloudFormation 用户指南 中的更新堆栈资源的行为。
语法
要在 AWS CloudFormation 模板中声明此实体,请使用以下语法:
JSON
{ "Type" : "AWS::AppSync::Resolver", "Properties" : { "ApiId" :
String
, "CachingConfig" :CachingConfig
, "DataSourceName" :String
, "FieldName" :String
, "Kind" :String
, "PipelineConfig" :PipelineConfig
, "RequestMappingTemplate" :String
, "RequestMappingTemplateS3Location" :String
, "ResponseMappingTemplate" :String
, "ResponseMappingTemplateS3Location" :String
, "SyncConfig" :SyncConfig
, "TypeName" :String
} }
YAML
Type: AWS::AppSync::Resolver Properties: ApiId:
String
CachingConfig:CachingConfig
DataSourceName:String
FieldName:String
Kind:String
PipelineConfig:PipelineConfig
RequestMappingTemplate:String
RequestMappingTemplateS3Location:String
ResponseMappingTemplate:String
ResponseMappingTemplateS3Location:String
SyncConfig:SyncConfig
TypeName:String
属性
ApiId
-
要将此解决程序附加到的 AWS AppSync GraphQL API。
必需:是
类型:字符串
Update requires: Replacement
CachingConfig
-
解决程序的缓存配置。
必需:否
Update requires: No interruption
DataSourceName
-
解决程序数据源名称。
必需:否
类型:字符串
Update requires: No interruption
FieldName
-
调用此解决程序的类型中的 GraphQL 字段。
必需:是
类型:字符串
Update requires: Replacement
Kind
-
解决程序类型。
-
UNIT:UNIT 解决程序类型。UNIT 解决程序是默认解决程序类型。UNIT 解决程序使您能够对单个数据源执行 GraphQL 查询。
-
PIPELINE:PIPELINE 解决程序类型。PIPELINE 解决程序使您能够以串行方式执行一系列
Function
。您可以使用管道解决程序对多个数据源执行 GraphQL 查询。
必需:否
类型:字符串
Update requires: No interruption
-
PipelineConfig
-
与管道解决程序关联的函数。
必需:否
Update requires: No interruption
RequestMappingTemplate
-
请求映射模板。
使用 Lambda 数据源时,请求映射模板是可选的。对于所有其他数据源,请求映射模板是必需的。
必需:否
类型:字符串
Update requires: No interruption
RequestMappingTemplateS3Location
-
请求映射模板在 Amazon S3 存储桶中的位置。如果要在 Amazon S3 中配置模板文件而不是将其嵌入 CloudFormation 模板中,请使用此项。
必需:否
类型:字符串
Update requires: No interruption
ResponseMappingTemplate
-
响应映射模板。
必需:否
类型:字符串
Update requires: No interruption
ResponseMappingTemplateS3Location
-
响应映射模板在 Amazon S3 存储桶中的位置。如果要在 Amazon S3 中配置模板文件而不是将其嵌入 CloudFormation 模板中,请使用此项。
必需:否
类型:字符串
Update requires: No interruption
SyncConfig
-
附加到版本控制的数据源的解决程序的
SyncConfig
。必需:否
类型:SyncConfig
Update requires: No interruption
TypeName
-
调用此解决程序的 GraphQL 类型。
必需:是
类型:字符串
Update requires: Replacement
返回值
Ref
如果将 AWS::AppSync::Resolver
资源的逻辑 ID 传递给内部 Ref
函数,则此函数将返回解决程序的 ARN,如 arn:aws:appsync:us-east-1:123456789012:apis/graphqlapiid/types/typename/resolvers/resolvername
。
有关使用 Ref
函数的更多信息,请参阅 Ref。
Fn::GetAtt
Fn::GetAtt
返回一个此类型指定属性的值。以下为可用属性和示例返回值。
有关使用 Fn::GetAtt
的更多信息,请参阅 Fn::GetAtt。
示例
解决程序创建示例
以下示例创建一个解决程序并通过将 GraphQL API ID 和数据源名称作为参数传递来将该解决程序与现有 GraphQL API 和数据源关联。
YAML
Parameters: graphQlApiId: Type: String dataSourceName: Type: String fieldName: Type: String typeName: Type: String requestMappingTemplateS3LocationInput: Type: String responseMappingTemplateS3LocationInput: Type: String Resources: Resolver: Type: AWS::AppSync::Resolver Properties: ApiId: Ref: graphQlApiId TypeName: Ref: typeName FieldName: Ref: fieldName DataSourceName: Ref: dataSourceName RequestMappingTemplateS3Location: Ref: requestMappingTemplateS3LocationInput ResponseMappingTemplateS3Location: Ref: responseMappingTemplateS3LocationInput
JSON
{ "Parameters": { "graphQlApiId": { "Type": "String" }, "dataSourceName": { "Type": "String" }, "fieldName": { "Type": "String" }, "typeName": { "Type": "String" }, "requestMappingTemplateS3LocationInput": { "Type": "String" }, "responseMappingTemplateS3LocationInput": { "Type": "String" } }, "Resources": { "Resolver": { "Type": "AWS::AppSync::Resolver", "Properties": { "ApiId": { "Ref": "graphQlApiId" }, "TypeName": { "Ref": "typeName" }, "FieldName": { "Ref": "fieldName" }, "DataSourceName": { "Ref": "dataSourceName" }, "RequestMappingTemplateS3Location": { "Ref": "requestMappingTemplateS3LocationInput" }, "ResponseMappingTemplateS3Location": { "Ref": "responseMappingTemplateS3LocationInput" } } } } }
另请参阅
-
AWS AppSync API 参考 中的 CreateResolver 操作。