Skip to content
v2.274.0

FunctionRuntime Class ​

Utility class for specifying specific appsync runtime versions.

Example ​

ts
declare const api: appsync.GraphqlApi;

const myJsFunction = new appsync.AppsyncFunction(this, 'function', {
  name: 'my_js_function',
  api,
  dataSource: api.addNoneDataSource('none'),
  code: appsync.Code.fromAsset('directory/function_code.js'),
  runtime: appsync.FunctionRuntime.JS_1_0_0,
});

new appsync.Resolver(this, 'PipelineResolver', {
  api,
  typeName: 'typeName',
  fieldName: 'fieldName',
  code: appsync.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: appsync.FunctionRuntime.JS_1_0_0,
  pipelineConfig: [myJsFunction],
});
python
# api: appsync.GraphqlApi


my_js_function = appsync.AppsyncFunction(self, "function",
    name="my_js_function",
    api=api,
    data_source=api.add_none_data_source("none"),
    code=appsync.Code.from_asset("directory/function_code.js"),
    runtime=appsync.FunctionRuntime.JS_1_0_0
)

appsync.Resolver(self, "PipelineResolver",
    api=api,
    type_name="typeName",
    field_name="fieldName",
    code=appsync.Code.from_inline("""
            // The before step
            export function request(...args) {
              console.log(args);
              return {}
            }

            // The after step
            export function response(ctx) {
              return ctx.prev.result
            }
          """),
    runtime=appsync.FunctionRuntime.JS_1_0_0,
    pipeline_config=[my_js_function]
)
java
GraphqlApi api;


AppsyncFunction myJsFunction = AppsyncFunction.Builder.create(this, "function")
        .name("my_js_function")
        .api(api)
        .dataSource(api.addNoneDataSource("none"))
        .code(Code.fromAsset("directory/function_code.js"))
        .runtime(FunctionRuntime.JS_1_0_0)
        .build();

Resolver.Builder.create(this, "PipelineResolver")
        .api(api)
        .typeName("typeName")
        .fieldName("fieldName")
        .code(Code.fromInline("\n    // The before step\n    export function request(...args) {\n      console.log(args);\n      return {}\n    }\n\n    // The after step\n    export function response(ctx) {\n      return ctx.prev.result\n    }\n  "))
        .runtime(FunctionRuntime.JS_1_0_0)
        .pipelineConfig(List.of(myJsFunction))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
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 }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var api GraphqlApi


myJsFunction := appsync.NewAppsyncFunction(this, jsii.String("function"), &AppsyncFunctionProps{
	Name: jsii.String("my_js_function"),
	Api: Api,
	DataSource: api.AddNoneDataSource(jsii.String("none")),
	Code: appsync.Code_FromAsset(jsii.String("directory/function_code.js")),
	Runtime: appsync.FunctionRuntime_JS_1_0_0(),
})

appsync.NewResolver(this, jsii.String("PipelineResolver"), &ResolverProps{
	Api: Api,
	TypeName: jsii.String("typeName"),
	FieldName: jsii.String("fieldName"),
	Code: appsync.Code_FromInline(jsii.String(`
	    // The before step
	    export function request(...args) {
	      console.log(args);
	      return {}
	    }

	    // The after step
	    export function response(ctx) {
	      return ctx.prev.result
	    }
	  `)),
	Runtime: appsync.FunctionRuntime_JS_1_0_0(),
	PipelineConfig: []IFunctionConfigurationRef{
		myJsFunction,
	},
})

Initializer ​

ts
new FunctionRuntime(family: FunctionRuntimeFamily, version: string)
python
FunctionRuntime(family: FunctionRuntimeFamily, version: str)
java
new FunctionRuntime(FunctionRuntimeFamily family, String version)
csharp
new FunctionRuntime(FunctionRuntimeFamily family, string version)
go
NewFunctionRuntime(Family FunctionRuntimeFamily, Version *string)

Properties ​

JS_1_0_0FunctionRuntimejs_1_0_0FunctionRuntimeJS_1_0_0FunctionRuntimeJS_1_0_0FunctionRuntimeJS_1_0_0FunctionRuntimerequiredstatic#
APPSYNC_JS v1.0.0 runtime.
namestringnamestrnameStringNamestringName*stringrequired#
The name of the runtime.
versionstringversionstrversionStringVersionstringVersion*stringrequired#
The runtime version.

Methods ​

toProperties(): RuntimeConfigdef to_properties(self, ) -> RuntimeConfigpublic RuntimeConfig toProperties()public RuntimeConfig ToProperties()func ToProperties() RuntimeConfig#
Convert to Cfn runtime configuration property format.