This is the new AWS CloudFormation Template Reference Guide. Please update your bookmarks and links. For help getting started with CloudFormation, see the AWS CloudFormation User Guide.
AWS::AppSync::Resolver
The AWS::AppSync::Resolver resource defines the logical GraphQL resolver
            that you attach to fields in a schema. Request and response templates for resolvers are
            written in Apache Velocity Template Language (VTL) format. For more information about
            resolvers, see Resolver
                Mapping Template Reference.
Note
When you submit an update, AWS CloudFormation updates resources based on differences between what you submit and the stack's current template. To cause this resource to be updated you must change a property value for this resource in the CloudFormation template. Changing the Amazon S3 file content without changing a property value will not result in an update operation.
See Update Behaviors of Stack Resources in the AWS CloudFormation User Guide.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::AppSync::Resolver", "Properties" : { "ApiId" :String, "CachingConfig" :CachingConfig, "Code" :String, "CodeS3Location" :String, "DataSourceName" :String, "FieldName" :String, "Kind" :String, "MaxBatchSize" :Integer, "MetricsConfig" :String, "PipelineConfig" :PipelineConfig, "RequestMappingTemplate" :String, "RequestMappingTemplateS3Location" :String, "ResponseMappingTemplate" :String, "ResponseMappingTemplateS3Location" :String, "Runtime" :AppSyncRuntime, "SyncConfig" :SyncConfig, "TypeName" :String} }
YAML
Type: AWS::AppSync::Resolver Properties: ApiId:StringCachingConfig:CachingConfigCode:StringCodeS3Location:StringDataSourceName:StringFieldName:StringKind:StringMaxBatchSize:IntegerMetricsConfig:StringPipelineConfig:PipelineConfigRequestMappingTemplate:StringRequestMappingTemplateS3Location:StringResponseMappingTemplate:StringResponseMappingTemplateS3Location:StringRuntime:AppSyncRuntimeSyncConfig:SyncConfigTypeName:String
Properties
- ApiId
- 
                    The AWS AppSync GraphQL API to which you want to attach this resolver. Required: Yes Type: String Update requires: Replacement 
- CachingConfig
- 
                    The caching configuration for the resolver. Required: No Type: CachingConfig Update requires: No interruption 
- Code
- 
                    The resolvercode that contains the request and response functions. When code is used, theruntimeis required. The runtime value must beAPPSYNC_JS.Required: No Type: String Update requires: No interruption 
- CodeS3Location
- 
                    The Amazon S3 endpoint. Required: No Type: String Update requires: No interruption 
- DataSourceName
- 
                    The resolver data source name. Required: No Type: String Pattern: [_A-Za-z][_0-9A-Za-z]*Minimum: 1Maximum: 65536Update requires: No interruption 
- FieldName
- 
                    The GraphQL field on a type that invokes the resolver. Required: Yes Type: String Update requires: Replacement 
- Kind
- 
                    The resolver type. - 
                            UNIT: A UNIT resolver type. A UNIT resolver is the default resolver type. You can use a UNIT resolver to run a GraphQL query against a single data source. 
- 
                            PIPELINE: A PIPELINE resolver type. You can use a PIPELINE resolver to invoke a series of Functionobjects in a serial manner. You can use a pipeline resolver to run a GraphQL query against multiple data sources.
 Required: No Type: String Allowed values: UNIT | PIPELINEUpdate requires: No interruption 
- 
                            
- MaxBatchSize
- 
                    The maximum number of resolver request inputs that will be sent to a single AWS Lambda function in a BatchInvokeoperation.Required: No Type: Integer Update requires: No interruption 
- MetricsConfig
- 
                    Enables or disables enhanced resolver metrics for specified resolvers. Note that MetricsConfigwon't be used unless theresolverLevelMetricsBehaviorvalue is set toPER_RESOLVER_METRICS. If theresolverLevelMetricsBehavioris set toFULL_REQUEST_RESOLVER_METRICSinstead,MetricsConfigwill be ignored. However, you can still set its value.Required: No Type: String Allowed values: ENABLED | DISABLEDUpdate requires: No interruption 
- PipelineConfig
- 
                    Functions linked with the pipeline resolver. Required: No Type: PipelineConfig Update requires: No interruption 
- RequestMappingTemplate
- 
                    The request mapping template. Request mapping templates are optional when using a Lambda data source. For all other data sources, a request mapping template is required. Required: No Type: String Pattern: ^.*$Minimum: 1Maximum: 65536Update requires: No interruption 
- RequestMappingTemplateS3Location
- 
                    The location of a request mapping template in an Amazon S3 bucket. Use this if you want to provision with a template file in Amazon S3 rather than embedding it in your CloudFormation template. Required: No Type: String Update requires: No interruption 
- ResponseMappingTemplate
- 
                    The response mapping template. Required: No Type: String Pattern: ^.*$Minimum: 1Maximum: 65536Update requires: No interruption 
- ResponseMappingTemplateS3Location
- 
                    The location of a response mapping template in an Amazon S3 bucket. Use this if you want to provision with a template file in Amazon S3 rather than embedding it in your CloudFormation template. Required: No Type: String Update requires: No interruption 
- Runtime
- 
                    Describes a runtime used by an AWS AppSync resolver or AWS AppSync function. Specifies the name and version of the runtime to use. Note that if a runtime is specified, code must also be specified. Required: No Type: AppSyncRuntime Update requires: No interruption 
- SyncConfig
- 
                    The SyncConfigfor a resolver attached to a versioned data source.Required: No Type: SyncConfig Update requires: No interruption 
- TypeName
- 
                    The GraphQL type that invokes this resolver. Required: Yes Type: String Update requires: Replacement 
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. 
For more information about using Fn::GetAtt, see Fn::GetAtt. 
- FieldName
- 
                            The GraphQL field on a type that invokes the resolver. 
- ResolverArn
- 
                            ARN of the resolver, such as arn:aws:appsync:us-east-1:123456789012:apis/graphqlapiid/types/typename/resolvers/resolvername.
- TypeName
- 
                            The GraphQL type that invokes this resolver. 
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 parameter.
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" } } } } }
See also
- 
                    CreateResolver operation in the AWS AppSync API Reference.