JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 48795
  • Score
    100M100P100Q156041F
  • License Apache-2.0

This project contains type definitions for AppSync resolver types.

Package Exports

  • @aws-appsync/utils
  • @aws-appsync/utils/dynamodb
  • @aws-appsync/utils/dynamodb.js
  • @aws-appsync/utils/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@aws-appsync/utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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;
}