Skip to content
v2.274.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#
The caching configuration for this resolver.

Default: No caching configuration

codeCodecodeCodecodeCodeCodeCodeCodeCode#
The function code.

Default: no code is used

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

Default: No max batch size

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

pipelineConfigIFunctionConfigurationRef[]pipeline_configtyping.List[IFunctionConfigurationRef]pipelineConfigList<IFunctionConfigurationRef>PipelineConfigIFunctionConfigurationRef[]PipelineConfig*[]IFunctionConfigurationRef#
configuration of the pipeline resolver.

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

requestMappingTemplateMappingTemplaterequest_mapping_templateMappingTemplaterequestMappingTemplateMappingTemplateRequestMappingTemplateMappingTemplateRequestMappingTemplateMappingTemplate#
The request mapping template for this resolver.

Default: No mapping template

responseMappingTemplateMappingTemplateresponse_mapping_templateMappingTemplateresponseMappingTemplateMappingTemplateResponseMappingTemplateMappingTemplateResponseMappingTemplateMappingTemplate#
The response mapping template for this resolver.

Default: No mapping template

The functions runtime.

Default: no function runtime, VTL mapping templates used

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