# Resolver

An AppSync resolver.

Extends: Construct › Resolver
Implements: IConstruct, IDependable

- CloudFormation: [`AWS::AppSync::Resolver`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-appsync-resolver.html)
- L1 type: [`CfnResolver`](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.CfnResolver.html)
- Source: [`aws-appsync/lib/resolver.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-appsync/lib/resolver.ts#L121)
- Type last changed: v2.60.0 · 12 Jan 2023

## 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'),
});
```

## Initializer

```ts
new Resolver(scope: Construct, id: string, props: ResolverProps)
```

## Construct Props

- `api`: [IGraphqlApi](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.IGraphqlApi.html) (required) — The API this resolver is attached to.

- `cachingConfig`: [CachingConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.CachingConfig.html) — The caching configuration for this resolver.

  **Default:** No caching configuration

- `code`: [Code](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.Code.html) — The function code.

  **Default:** no code is used

- `dataSource`: [BaseDataSource](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.BaseDataSource.html) — The data source this resolver is using.

  **Default:** No datasource

- `fieldName`: string (required) — name of the GraphQL field in the given type this resolver is attached to.

- `maxBatchSize`: number — The maximum number of elements per batch, when using batch invoke.

  **Default:** No max batch size

- `metricsConfig`: [ResolverMetricsConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.ResolverMetricsConfig.html) — 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

- `pipelineConfig`: [IFunctionConfigurationRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_appsync.IFunctionConfigurationRef.html)[] — configuration of the pipeline resolver.

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

- `requestMappingTemplate`: [MappingTemplate](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.MappingTemplate.html) — The request mapping template for this resolver.

  **Default:** No mapping template

- `responseMappingTemplate`: [MappingTemplate](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.MappingTemplate.html) — The response mapping template for this resolver.

  **Default:** No mapping template

- `runtime`: [FunctionRuntime](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.FunctionRuntime.html) — The functions runtime.

  **Default:** no function runtime, VTL mapping templates used

- `typeName`: string (required) — name of the GraphQL type this resolver is attached to.

## Properties

- `arn`: string — the ARN of the resolver.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

## Methods

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  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**

  - `x` — Any object.

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

- `toString(): string` — Returns a string representation of this construct.

- `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.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
