aws-cdk-lib.aws_appsync.AppsyncFunction

class AppsyncFunction (construct)

LanguageType name
.NETAmazon.CDK.AWS.AppSync.AppsyncFunction
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsappsync#AppsyncFunction
Javasoftware.amazon.awscdk.services.appsync.AppsyncFunction
Pythonaws_cdk.aws_appsync.AppsyncFunction
TypeScript (source)aws-cdk-lib » aws_appsync » AppsyncFunction

Implements IConstruct, IDependable, IResource, IAppsyncFunction

AppSync Functions are local functions that perform certain operations onto a backend data source.

Developers can compose operations (Functions) and execute them in sequence with Pipeline Resolvers.

Example

declare const api: appsync.GraphqlApi;

const appsyncFunction = new appsync.AppsyncFunction(this, 'function', {
  name: 'appsync_function',
  api,
  dataSource: api.addNoneDataSource('none'),
  requestMappingTemplate: appsync.MappingTemplate.fromFile('request.vtl'),
  responseMappingTemplate: appsync.MappingTemplate.fromFile('response.vtl'),
});

Initializer

new AppsyncFunction(scope: Construct, id: string, props: AppsyncFunctionProps)

Parameters

  • scope Construct
  • id string
  • props AppsyncFunctionProps

Construct Props

NameTypeDescription
apiIGraphqlApithe GraphQL Api linked to this AppSync Function.
dataSourceBaseDataSourcethe data source linked to this AppSync Function.
namestringthe name of the AppSync Function.
code?CodeThe function code.
description?stringthe description for this AppSync Function.
requestMappingTemplate?MappingTemplatethe request mapping template for the AppSync Function.
responseMappingTemplate?MappingTemplatethe response mapping template for the AppSync Function.
runtime?FunctionRuntimeThe functions runtime.

api

Type: IGraphqlApi

the GraphQL Api linked to this AppSync Function.


dataSource

Type: BaseDataSource

the data source linked to this AppSync Function.


name

Type: string

the name of the AppSync Function.


code?

Type: Code (optional, default: no code is used)

The function code.


description?

Type: string (optional, default: no description)

the description for this AppSync Function.


requestMappingTemplate?

Type: MappingTemplate (optional, default: no request mapping template)

the request mapping template for the AppSync Function.


responseMappingTemplate?

Type: MappingTemplate (optional, default: no response mapping template)

the response mapping template for the AppSync Function.


runtime?

Type: FunctionRuntime (optional, default: no function runtime, VTL mapping templates used)

The functions runtime.

Properties

NameTypeDescription
dataSourceBaseDataSourcethe data source of this AppSync Function.
envResourceEnvironmentThe environment this resource belongs to.
functionArnstringthe ARN of the AppSync function.
functionIdstringthe ID of the AppSync function.
functionNamestringthe name of this AppSync Function.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.

dataSource

Type: BaseDataSource

the data source of this AppSync Function.


env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


functionArn

Type: string

the ARN of the AppSync function.


functionId

Type: string

the ID of the AppSync function.


functionName

Type: string

the name of this AppSync Function.


node

Type: Node

The tree node.


stack

Type: Stack

The stack in which this resource is defined.

Methods

NameDescription
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
toString()Returns a string representation of this construct.
static fromAppsyncFunctionAttributes(scope, id, attrs)Import Appsync Function from arn.

applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static fromAppsyncFunctionAttributes(scope, id, attrs)

public static fromAppsyncFunctionAttributes(scope: Construct, id: string, attrs: AppsyncFunctionAttributes): IAppsyncFunction

Parameters

  • scope Construct
  • id string
  • attrs AppsyncFunctionAttributes

Returns

  • IAppsyncFunction

Import Appsync Function from arn.