Back to Serverless

Pipeline functions

docs/sf/providers/aws/guide/appsync/pipeline-functions.md

4.29.02.2 KB
Original Source
<!-- title: Serverless Framework - AppSync - Pipeline Functions description: How to configure pipeline functions for AWS AppSync with the Serverless Framework. short_title: AppSync - Pipeline Functions keywords: [ 'Serverless Framework', 'AppSync', 'Pipeline Functions', 'Resolvers', 'GraphQL', 'AWS', ] -->

Pipeline functions

When you use PIPELINE resolvers, you will also need to define the used pipeline functions. You can do so under the appSync.pipelineFunctions attribute.

It's a key-value pair object whose key is the name of the function and the value is its configuration.

Quick start

yaml
appSync:
  pipelineFunctions:
    myFunction:
      dataSource: myDataSource
      code: myFunction.js

Configuration

  • dataSource: The name of the dataSource to use.
  • description: An optional description for this pipeline function.
  • code: The path to the JS resolver handler file, relative to serverless.yml.
  • request: The path to the VTL request mapping template file, relative to serverless.yml.
  • response: The path to the VTL response mapping template file, relative to serverless.yml.
  • maxBatchSize: The maximum batch size to use (only available for AWS Lambda DataSources)
  • substitutions: See Variable Substitutions
  • sync: See SyncConfig

JavaScript vs VTL vs Direct Lambda

When code is specified, the JavaScript runtime is used. When request and/or response are specified, the VTL runtime is used.

To use direct lambda, don't specify anything (only works with Lambda function data sources).

Inline DataSources

Just like with UNIT resolvers, you can define the dataSource inline in pipeline functions.

yaml
appSync:
  pipelineFunctions:
    myFunction:
      dataSource:
        type: 'AWS_LAMBDA'
        config:
          function:
            timeout: 30
            handler: 'functions/myFunction.handler'