Code Class
Represents source code for an AppSync Function or Resolver.
Example
ts
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
ts
new Code()
python
Code()
java
new Code()
csharp
new Code()
go
NewCode()
Methods
bind(scope: Construct): CodeConfigdef bind(self, scope: Construct) -> CodeConfigpublic CodeConfig bind(Construct scope)public CodeConfig Bind(Construct scope)func Bind(Scope Construct) CodeConfig#Bind source code to an AppSync Function or resolver.
fromAsset(path: string, options?: AssetOptions): AssetCode@staticmethod def from_asset(path: str, options: typing.Optional[AssetOptions] = None) -> AssetCodepublic static AssetCode fromAsset(String path, AssetOptions options)public static AssetCode FromAsset(string path, AssetOptions? options = null)func FromAsset(Path *string, Options AssetOptions) AssetCodestatic#Loads the function code from a local disk path.
1 parameter
Parameters
pathpathpathpathPath— The path to the source code file.
fromInline(code: string): InlineCode@staticmethod def from_inline(code: str) -> InlineCodepublic static InlineCode fromInline(String code)public static InlineCode FromInline(string code)func FromInline(Code *string) InlineCodestatic#Inline code for AppSync function.
1 parameter · returns
Parameters
codecodecodecodeCode— The actual handler code (the resulting zip file cannot exceed 4MB).
Returns: InlineCode with inline code.