Resource: awsAppsyncResolver
Provides an AppSync Resolver.
Example Usage
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsAppsyncGraphqlApiTest = new aws.appsyncGraphqlApi.AppsyncGraphqlApi(
  this,
  "test",
  {
    authenticationType: "API_KEY",
    name: "tf-example",
    schema:
      "type Mutation {\n\tputPost(id: ID!, title: String!): Post\n}\n\ntype Post {\n\tid: ID!\n\ttitle: String!\n}\n\ntype Query {\n\tsinglePost(id: ID!): Post\n}\n\nschema {\n\tquery: Query\n\tmutation: Mutation\n}\n",
  }
);
new aws.appsyncResolver.AppsyncResolver(this, "Mutation_pipelineTest", {
  apiId: awsAppsyncGraphqlApiTest.id,
  field: "pipelineTest",
  kind: "PIPELINE",
  pipelineConfig: {
    functions: [
      "${aws_appsync_function.test1.function_id}",
      "${aws_appsync_function.test2.function_id}",
      "${aws_appsync_function.test3.function_id}",
    ],
  },
  requestTemplate: "{}",
  responseTemplate: "$util.toJson($ctx.result)",
  type: "Mutation",
});
const awsAppsyncDatasourceTest = new aws.appsyncDatasource.AppsyncDatasource(
  this,
  "test_2",
  {
    apiId: awsAppsyncGraphqlApiTest.id,
    httpConfig: {
      endpoint: "http://example.com",
    },
    name: "tf_example",
    type: "HTTP",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsAppsyncDatasourceTest.overrideLogicalId("test");
const awsAppsyncResolverTest = new aws.appsyncResolver.AppsyncResolver(
  this,
  "test_3",
  {
    apiId: awsAppsyncGraphqlApiTest.id,
    cachingConfig: {
      cachingKeys: ["$context.identity.sub", "$context.arguments.id"],
      ttl: 60,
    },
    dataSource: awsAppsyncDatasourceTest.name,
    field: "singlePost",
    requestTemplate:
      '{\n    "version": "2018-05-29",\n    "method": "GET",\n    "resourcePath": "/",\n    "params":{\n        "headers": $utils.http.copyheaders($ctx.request.headers)\n    }\n}\n',
    responseTemplate:
      "#if($ctx.result.statusCode == 200)\n    $ctx.result.body\n#else\n    $utils.appendError($ctx.result.body, $ctx.result.statusCode)\n#end\n",
    type: "Query",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsAppsyncResolverTest.overrideLogicalId("test");
Example Usage JS
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.appsyncResolver.AppsyncResolver(this, "example", {
  apiId: "${aws_appsync_graphql_api.test.id}",
  code: '${file("some-code-dir")}',
  field: "pipelineTest",
  kind: "PIPELINE",
  pipelineConfig: {
    functions: ["${aws_appsync_function.test.function_id}"],
  },
  runtime: {
    name: "APPSYNC_JS",
    runtimeVersion: "1.0.0",
  },
  type: "Query",
});
Argument Reference
The following arguments are supported:
apiId- (Required) API ID for the GraphQL API.code- (Optional) The function code that contains the request and response functions. When code is used, the runtime is required. The runtime value must be APPSYNC_JS.type- (Required) Type name from the schema defined in the GraphQL API.field- (Required) Field name from the schema defined in the GraphQL API.requestTemplate- (Optional) Request mapping template for UNIT resolver or 'before mapping template' for PIPELINE resolver. Required for non-Lambda resolvers.responseTemplate- (Optional) Response mapping template for UNIT resolver or 'after mapping template' for PIPELINE resolver. Required for non-Lambda resolvers.dataSource- (Optional) Data source name.maxBatchSize- (Optional) Maximum batching size for a resolver. Valid values are between0and2000.kind- (Optional) Resolver type. Valid values areunitandpipeline.syncConfig- (Optional) Describes a Sync configuration for a resolver. See Sync Config.pipelineConfig- (Optional) The caching configuration for the resolver. See Pipeline Config.cachingConfig- (Optional) The Caching Config. See Caching Config.runtime- (Optional) Describes a runtime used by an AWS AppSync pipeline 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. See Runtime.
Caching Config
cachingKeys- (Optional) The caching keys for a resolver that has caching activated. Valid values are entries from the $context.arguments, $context.source, and $context.identity maps.ttl- (Optional) The TTL in seconds for a resolver that has caching activated. Valid values are between1and3600seconds.
Pipeline Config
functions- (Optional) A list of Function objects.
Sync Config
conflictDetection- (Optional) Conflict Detection strategy to use. Valid values arenoneandversion.conflictHandler- (Optional) Conflict Resolution strategy to perform in the event of a conflict. Valid values arenone,OPTIMISTIC_CONCURRENCY,automerge, andlambda.lambdaConflictHandlerConfig- (Optional) Lambda Conflict Handler Config when configuringlambdaas the Conflict Handler. See Lambda Conflict Handler Config.
Lambda Conflict Handler Config
lambdaConflictHandlerArn- (Optional) ARN for the Lambda function to use as the Conflict Handler.
Runtime
name- (Optional) The name of the runtime to use. Currently, the only allowed value isAPPSYNC_JS.runtimeVersion- (Optional) The version of the runtime to use. Currently, the only allowed version is100.
Attributes Reference
In addition to all arguments above, the following attributes are exported:
arn- ARN
Import
awsAppsyncResolver can be imported with their apiId, a hyphen, type, a hypen and field e.g.,