AWS::AppSync::Resolver
The
AWS::AppSync::Resolver resource defines the logical GraphQL resolver that you will attach to fields in a
schema.
Request and Response templates for resolvers are written in Apache Velocity Template
Language (VTL) format.
More information on resolvers can be found in the
Resolver Mapping Template Reference.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::AppSync::Resolver", "Properties" : { "ResponseMappingTemplateS3Location" :String, "TypeName" :String, "DataSourceName" :String, "RequestMappingTemplate" :String, "ResponseMappingTemplate" :String, "RequestMappingTemplateS3Location" :String, "ApiId" :String, "FieldName" :String, "Kind" :String, "PipelineConfig" : PipelineConfig } }
YAML
Type: "AWS::AppSync::Resolver" Properties: ResponseMappingTemplateS3Location:StringTypeName:StringDataSourceName:StringRequestMappingTemplate:StringResponseMappingTemplate:StringRequestMappingTemplateS3Location:StringApiId:StringFieldName:StringKind:StringPipelineConfig: PipelineConfig
Properties
ResponseMappingTemplateS3Location-
A location of a response mapping template on an S3 bucket if you wish to provision with the template file living in S3 rather than embedded in your CloudFormation template.
Required: No
Type: String
Update requires: No interruption
TypeName-
The GraphQL type that will invoke this resolver.
Required: Yes
Type: String
Update requires: Replacement
DataSourceName-
The AWS AppSync data source that this resolver will run against in order to return data to the caller.
Required: Yes
Type: String
Update requires: No interruption
RequestMappingTemplate-
The resolver’s request mapping template, written in text within the CloudFormation template.
Required: No
Type: String
Update requires: No interruption
ResponseMappingTemplate-
The resolver’s response mapping template, written in text within the CloudFormation template.
Required: No
Type: String
Update requires: No interruption
RequestMappingTemplateS3Location-
A location of a request mapping template on an S3 bucket if you wish to provision with the template file living in S3 rather than embedded in your CloudFormation template.
Required: No
Type: String
Update requires: No interruption
ApiId-
The AWS AppSync GraphQL API which you will attach this resolver.
Required: Yes
Type: String
Update requires: Replacement
FieldName-
The GraphQL field on a type that will invoke the resolver.
Required: Yes
Type: String
Update requires: Replacement
Kind-
The kind of the resolver.
Valid values:
UNIT|PIPELINE.Required: No
Type: String
Update requires: Replacement
PipelineConfig-
Functions linked with the pipeline resolver.
Required: No
Type: PipelineConfig
Update requires: No interruption
Return Values
Ref
When you pass the logical ID of an
AWS::AppSync::Resolver
resource to the intrinsic
Ref function, the function returns the
ARN of the Resolver, such as
arn:aws:appsync:us-east-1:123456789012:apis/graphqlapiid/types/typename/resolvers/resolvername.
For more information about using the
Ref function, see
Ref.
Fn::GetAtt
Fn::GetAtt returns a value for a specified attribute of this type.
The following are the available attributes and sample return values.
TypeName-
The GraphQL type that will invoke this resolver.
ResolverArn-
ARN of the Resolver, such as
arn:aws:appsync:us-east-1:123456789012:apis/graphqlapiid/types/typename/resolvers/resolvername. FieldName-
The GraphQL field on a type that will invoke the resolver.
For more information about using
Fn::GetAtt, see
Fn::GetAtt.
Examples
Resolver creation example
The following example creates a resolver and associates it with an existing GraphQL API and a data source by passing the GraphQL API Id and data source name as a paramater.
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" } } } } }
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
See Also
-
CreateResolver operation in the AWS AppSync API Reference
