Class Code
Represents source code for an AppSync Function or Resolver.
Namespace: Amazon.CDK.AWS.AppSync
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public abstract class Code : DeputyBase
Syntax (vb)
Public MustInherit Class Code
Inherits DeputyBase
Remarks
ExampleMetadata: infused
Examples
GraphqlApi api;
var myJsFunction = new AppsyncFunction(this, "function", new AppsyncFunctionProps {
Name = "my_js_function",
Api = api,
DataSource = api.AddNoneDataSource("none"),
Code = Code.FromAsset("directory/function_code.js"),
Runtime = FunctionRuntime.JS_1_0_0
});
new Resolver(this, "PipelineResolver", new ResolverProps {
Api = api,
TypeName = "typeName",
FieldName = "fieldName",
Code = Code.FromInline(@"
// The before step
export function request(...args) {
console.log(args);
return {}
}
// The after step
export function response(ctx) {
return ctx.prev.result
}
"),
Runtime = FunctionRuntime.JS_1_0_0,
PipelineConfig = new [] { myJsFunction }
});
Synopsis
Constructors
Code() | |
Code(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
Code(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Methods
Bind(Construct) | Bind source code to an AppSync Function or resolver. |
FromAsset(String, IAssetOptions) | Loads the function code from a local disk path. |
FromInline(String) | Inline code for AppSync function. |
Constructors
Code()
protected Code()
Code(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected Code(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
Code(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected Code(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Methods
Bind(Construct)
Bind source code to an AppSync Function or resolver.
public abstract ICodeConfig Bind(Construct scope)
Parameters
- scope Constructs.Construct
Returns
FromAsset(String, IAssetOptions)
Loads the function code from a local disk path.
public static AssetCode FromAsset(string path, IAssetOptions options = null)
Parameters
- path System.String
The path to the source code file.
- options IAssetOptions
The path to the source code file.
Returns
FromInline(String)
Inline code for AppSync function.
public static InlineCode FromInline(string code)
Parameters
- code System.String
The actual handler code (the resulting zip file cannot exceed 4MB).
Returns
InlineCode
with inline code.