@aws-appsync/utils
TypeScript icon, indicating that this package has built-in type declarations

1.8.0 • Public • Published

Type definition for @aws-appsync/utils

This project contains utility function definitions and type definitions for working with AWS AppSync Resolvers written in JavaScript using the APPSYNC_JS runtime. This includes the util and extensions utilities. For more information on these utilities, see the AppSync documentation.

Usage

Install the type definition by running

npm install @aws-appsync/utils

In your AppSync function code definition:

import { util } from '@aws-appsync/utils';
import * as ddb from '@aws-appsync/utils/dynamodb';

/**
 * Creates a new item in a DynamoDB table
 * @param ctx contextual information about the request
 */
export function request(ctx) {
  const item = ctx.arguments.input;
  return ddb.put({ key: { id: util.autoId() }, item });
}

/**
 * Returns the result
 * @param ctx contextual information about the request
 */
export function response(ctx) {
  const { error, result } = ctx;
  if (error) {
    return util.appendError(error.message, error.type, result);
  }
  return ctx.result;
}

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i @aws-appsync/utils

    Weekly Downloads

    22,229

    Version

    1.8.0

    License

    Apache-2.0

    Unpacked Size

    131 kB

    Total Files

    52

    Last publish

    Collaborators

    • gilbertw1
    • yathiraj