java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.appsync.Code
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
Direct Known Subclasses:
AssetCode, InlineCode

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-12-06T14:43:14.358Z") @Stability(Stable) public abstract class Code extends software.amazon.jsii.JsiiObject
Represents source code for an AppSync Function or Resolver.

Example:

 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();
 
  • Nested Class Summary

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
    protected
    Code(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    Code(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract CodeConfig
    bind(software.constructs.Construct scope)
    Bind source code to an AppSync Function or resolver.
    static AssetCode
    Loads the function code from a local disk path.
    static AssetCode
    fromAsset(String path, AssetOptions options)
    Loads the function code from a local disk path.
    static InlineCode
    Inline code for AppSync function.

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Constructor Details

    • Code

      protected Code(software.amazon.jsii.JsiiObjectRef objRef)
    • Code

      protected Code(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Code

      @Stability(Stable) protected Code()
  • Method Details

    • fromAsset

      @Stability(Stable) @NotNull public static AssetCode fromAsset(@NotNull String path, @Nullable AssetOptions options)
      Loads the function code from a local disk path.

      Parameters:
      path - The path to the source code file. This parameter is required.
      options -
    • fromAsset

      @Stability(Stable) @NotNull public static AssetCode fromAsset(@NotNull String path)
      Loads the function code from a local disk path.

      Parameters:
      path - The path to the source code file. This parameter is required.
    • fromInline

      @Stability(Stable) @NotNull public static InlineCode fromInline(@NotNull String code)
      Inline code for AppSync function.

      Parameters:
      code - The actual handler code (limited to 4KiB). This parameter is required.
      Returns:
      InlineCode with inline code.
    • bind

      @Stability(Stable) @NotNull public abstract CodeConfig bind(@NotNull software.constructs.Construct scope)
      Bind source code to an AppSync Function or resolver.

      Parameters:
      scope - This parameter is required.