class Code
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.AppSync.Code |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsappsync#Code |
Java | software.amazon.awscdk.services.appsync.Code |
Python | aws_cdk.aws_appsync.Code |
TypeScript (source) | aws-cdk-lib » aws_appsync » Code |
Implemented by
Asset, Inline
Represents source code for an AppSync Function or Resolver.
Example
declare const api: appsync.EventApi;
declare const lambdaDataSource: appsync.AppSyncLambdaDataSource;
// Lambda data source for publish handler
api.addChannelNamespace('lambda-ns', {
code: appsync.Code.fromInline('/* event handler code here.*/'),
publishHandlerConfig: {
dataSource: lambdaDataSource,
},
});
// Direct Lambda data source for publish handler
api.addChannelNamespace('lambda-direct-ns', {
publishHandlerConfig: {
dataSource: lambdaDataSource,
direct: true,
},
});
api.addChannelNamespace('lambda-direct-async-ns', {
publishHandlerConfig: {
dataSource: lambdaDataSource,
direct: true,
lambdaInvokeType: appsync.LambdaInvokeType.EVENT,
},
});
Initializer
new Code()
Methods
| Name | Description |
|---|---|
| bind(scope) | Bind source code to an AppSync Function or resolver. |
| static from | Loads the function code from a local disk path. |
| static from | Inline code for AppSync function. |
bind(scope)
public bind(scope: Construct): CodeConfig
Parameters
- scope
Construct
Returns
Bind source code to an AppSync Function or resolver.
static fromAsset(path, options?)
public static fromAsset(path: string, options?: AssetOptions): AssetCode
Parameters
- path
string— The path to the source code file. - options
AssetOptions
Returns
Loads the function code from a local disk path.
static fromInline(code)
public static fromInline(code: string): InlineCode
Parameters
- code
string— The actual handler code (the resulting zip file cannot exceed 4MB).
Returns
Inline code for AppSync function.

.NET
Go
Java
Python
TypeScript (