Skip to content
v2.275.0

Resolver ​

An AppSync resolver.

Example ​

ts
declare const api: appsync.GraphqlApi;
declare const appsyncFunction: appsync.AppsyncFunction;

const pipelineResolver = new appsync.Resolver(this, 'pipeline', {
  api,
  dataSource: api.addNoneDataSource('none'),
  typeName: 'typeName',
  fieldName: 'fieldName',
  requestMappingTemplate: appsync.MappingTemplate.fromFile('beforeRequest.vtl'),
  pipelineConfig: [appsyncFunction],
  responseMappingTemplate: appsync.MappingTemplate.fromFile('afterResponse.vtl'),
});
python
# api: appsync.GraphqlApi
# appsync_function: appsync.AppsyncFunction


pipeline_resolver = appsync.Resolver(self, "pipeline",
    api=api,
    data_source=api.add_none_data_source("none"),
    type_name="typeName",
    field_name="fieldName",
    request_mapping_template=appsync.MappingTemplate.from_file("beforeRequest.vtl"),
    pipeline_config=[appsync_function],
    response_mapping_template=appsync.MappingTemplate.from_file("afterResponse.vtl")
)
java
GraphqlApi api;
AppsyncFunction appsyncFunction;


Resolver pipelineResolver = Resolver.Builder.create(this, "pipeline")
        .api(api)
        .dataSource(api.addNoneDataSource("none"))
        .typeName("typeName")
        .fieldName("fieldName")
        .requestMappingTemplate(MappingTemplate.fromFile("beforeRequest.vtl"))
        .pipelineConfig(List.of(appsyncFunction))
        .responseMappingTemplate(MappingTemplate.fromFile("afterResponse.vtl"))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
GraphqlApi api;
AppsyncFunction appsyncFunction;


var pipelineResolver = new Resolver(this, "pipeline", new ResolverProps {
    Api = api,
    DataSource = api.AddNoneDataSource("none"),
    TypeName = "typeName",
    FieldName = "fieldName",
    RequestMappingTemplate = MappingTemplate.FromFile("beforeRequest.vtl"),
    PipelineConfig = new [] { appsyncFunction },
    ResponseMappingTemplate = MappingTemplate.FromFile("afterResponse.vtl")
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var api GraphqlApi
var appsyncFunction AppsyncFunction


pipelineResolver := appsync.NewResolver(this, jsii.String("pipeline"), &ResolverProps{
	Api: Api,
	DataSource: api.AddNoneDataSource(jsii.String("none")),
	TypeName: jsii.String("typeName"),
	FieldName: jsii.String("fieldName"),
	RequestMappingTemplate: appsync.MappingTemplate_FromFile(jsii.String("beforeRequest.vtl")),
	PipelineConfig: []IFunctionConfigurationRef{
		appsyncFunction,
	},
	ResponseMappingTemplate: appsync.MappingTemplate_*FromFile(jsii.String("afterResponse.vtl")),
})

Initializer ​

ts
new Resolver(scope: Construct, id: string, props: ResolverProps)
python
Resolver(scope: Construct, id: str, props: ResolverProps)
java
new Resolver(Construct scope, String id, ResolverProps props)
csharp
new Resolver(Construct scope, string id, ResolverProps props)
go
NewResolver(Scope Construct, Id *string, Props ResolverProps)

Construct Props ​

The API this resolver is attached to.
cachingConfigoptionalCachingConfigcaching_configoptionalCachingConfigcachingConfigoptionalCachingConfigCachingConfigoptionalCachingConfigCachingConfigoptionalCachingConfig#
The caching configuration for this resolver.

Default: No caching configuration

codeoptionalCodecodeoptionalCodecodeoptionalCodeCodeoptionalCodeCodeoptionalCode#
The function code.

Default: no code is used

dataSourceoptionalBaseDataSourcedata_sourceoptionalBaseDataSourcedataSourceoptionalBaseDataSourceDataSourceoptionalBaseDataSourceDataSourceoptionalBaseDataSource#
The data source this resolver is using.

Default: No datasource

fieldNamestringfield_namestrfieldNameStringFieldNamestringFieldName*stringrequired#
name of the GraphQL field in the given type this resolver is attached to.
maxBatchSizeoptionalnumbermax_batch_sizeoptionalint | floatmaxBatchSizeoptionalNumberMaxBatchSizeoptionaldoubleMaxBatchSizeoptional*float64#
The maximum number of elements per batch, when using batch invoke.

Default: No max batch size

metricsConfigoptionalResolverMetricsConfigmetrics_configoptionalResolverMetricsConfigmetricsConfigoptionalResolverMetricsConfigMetricsConfigoptionalResolverMetricsConfigMetricsConfigoptionalResolverMetricsConfig#
Whether to enable enhanced metrics Value will be ignored, if `enhancedMetricsConfig.resolverLevelMetricsBehavior` on AppSync GraphqlApi construct is set to `FULL_REQUEST_RESOLVER_METRICS`.

Default: no metrics configuration

pipelineConfigoptionalIFunctionConfigurationRef[]pipeline_configoptionaltyping.List[IFunctionConfigurationRef]pipelineConfigoptionalList<IFunctionConfigurationRef>PipelineConfigoptionalIFunctionConfigurationRef[]PipelineConfigoptional*[]IFunctionConfigurationRef#
configuration of the pipeline resolver.

Default: no pipeline resolver configuration An empty array | undefined sets resolver to be of kind, unit

requestMappingTemplateoptionalMappingTemplaterequest_mapping_templateoptionalMappingTemplaterequestMappingTemplateoptionalMappingTemplateRequestMappingTemplateoptionalMappingTemplateRequestMappingTemplateoptionalMappingTemplate#
The request mapping template for this resolver.

Default: No mapping template

responseMappingTemplateoptionalMappingTemplateresponse_mapping_templateoptionalMappingTemplateresponseMappingTemplateoptionalMappingTemplateResponseMappingTemplateoptionalMappingTemplateResponseMappingTemplateoptionalMappingTemplate#
The response mapping template for this resolver.

Default: No mapping template

runtimeoptionalFunctionRuntimeruntimeoptionalFunctionRuntimeruntimeoptionalFunctionRuntimeRuntimeoptionalFunctionRuntimeRuntimeoptionalFunctionRuntime#
The functions runtime.

Default: no function runtime, VTL mapping templates used

typeNamestringtype_namestrtypeNameStringTypeNamestringTypeName*stringrequired#
name of the GraphQL type this resolver is attached to.

Properties ​

arnstringarnstrarnStringArnstringArn*string#
the ARN of the resolver.
nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.

Methods ​

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining