Skip to content
v2.273.0

BaseResolverProps Struct ​

Basic properties for an AppSync resolver.

Example ​

ts
// Create username and password secret for DB Cluster
const secret = new rds.DatabaseSecret(this, 'AuroraSecret', {
  username: 'clusteradmin',
});

// The VPC to place the cluster in
const vpc = new ec2.Vpc(this, 'AuroraVpc');

// Create the serverless cluster, provide all values needed to customise the database.
const cluster = new rds.ServerlessCluster(this, 'AuroraCluster', {
  engine: rds.DatabaseClusterEngine.AURORA_MYSQL,
  vpc,
  credentials: { username: 'clusteradmin' },
  clusterIdentifier: 'db-endpoint-test',
  defaultDatabaseName: 'demos',
});

// Build a data source for AppSync to access the database.
declare const api: appsync.GraphqlApi;
const rdsDS = api.addRdsDataSource('rds', cluster, secret, 'demos');

// Set up a resolver for an RDS query.
rdsDS.createResolver('QueryGetDemosRdsResolver', {
  typeName: 'Query',
  fieldName: 'getDemosRds',
  requestMappingTemplate: appsync.MappingTemplate.fromString(`
  {
    "version": "2018-05-29",
    "statements": [
      "SELECT * FROM demos"
    ]
  }
  `),
  responseMappingTemplate: appsync.MappingTemplate.fromString(`
    $utils.toJson($utils.rds.toJsonObject($ctx.result)[0])
  `),
});

// Set up a resolver for an RDS mutation.
rdsDS.createResolver('MutationAddDemoRdsResolver', {
  typeName: 'Mutation',
  fieldName: 'addDemoRds',
  requestMappingTemplate: appsync.MappingTemplate.fromString(`
  {
    "version": "2018-05-29",
    "statements": [
      "INSERT INTO demos VALUES (:id, :version)",
      "SELECT * WHERE id = :id"
    ],
    "variableMap": {
      ":id": $util.toJson($util.autoId()),
      ":version": $util.toJson($ctx.args.version)
    }
  }
  `),
  responseMappingTemplate: appsync.MappingTemplate.fromString(`
    $utils.toJson($utils.rds.toJsonObject($ctx.result)[1][0])
  `),
});

Properties ​

cachingConfigCachingConfigcaching_configCachingConfigcachingConfigCachingConfigCachingConfigCachingConfigCachingConfigCachingConfig= No caching configuration#
The caching configuration for this resolver.
codeCodecodeCodecodeCodeCodeCodeCodeCode= no code is used#
The function code.
fieldNamestringfield_namestrfieldNameStringFieldNamestringFieldName*stringrequired#
name of the GraphQL field in the given type this resolver is attached to.
maxBatchSizenumbermax_batch_sizeint | floatmaxBatchSizeNumberMaxBatchSizedoubleMaxBatchSize*float64= No max batch size#
The maximum number of elements per batch, when using batch invoke.
metricsConfigResolverMetricsConfigmetrics_configResolverMetricsConfigmetricsConfigResolverMetricsConfigMetricsConfigResolverMetricsConfigMetricsConfigResolverMetricsConfig= no metrics configuration#
Whether to enable enhanced metrics Value will be ignored, if `enhancedMetricsConfig.resolverLevelMetricsBehavior` on AppSync GraphqlApi construct is set to `FULL_REQUEST_RESOLVER_METRICS`.
pipelineConfigIFunctionConfigurationRef[]pipeline_configtyping.List[IFunctionConfigurationRef]pipelineConfigList<IFunctionConfigurationRef>PipelineConfigIFunctionConfigurationRef[]PipelineConfig*[]IFunctionConfigurationRef= no pipeline resolver configurati…#
configuration of the pipeline resolver.
default

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

requestMappingTemplateMappingTemplaterequest_mapping_templateMappingTemplaterequestMappingTemplateMappingTemplateRequestMappingTemplateMappingTemplateRequestMappingTemplateMappingTemplate= No mapping template#
The request mapping template for this resolver.
responseMappingTemplateMappingTemplateresponse_mapping_templateMappingTemplateresponseMappingTemplateMappingTemplateResponseMappingTemplateMappingTemplateResponseMappingTemplateMappingTemplate= No mapping template#
The response mapping template for this resolver.
runtimeFunctionRuntimeruntimeFunctionRuntimeruntimeFunctionRuntimeRuntimeFunctionRuntimeRuntimeFunctionRuntime= no function runtime, VTL mapping…#
The functions runtime.
default

Default: no function runtime, VTL mapping templates used

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