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

2.0.0 • Public • Published

Appsync API Gateway

Utility method for making API calls to AppSync from Lambdas in AWS.

This library essentially implements the suggested approach outlined by AWS Amplify Docs in a nice package.

Usage

Install via NPM:

npm i @crft/appsync-gateway --save

then use like:

const {
  GraphQLGateway,
  IAMCredentialsStrategy,
  APIKeyCredentialsStrategy,
  AuthHeaderCredentialsStrategy
} = require('@crft/appsync-gateway');

// IAM Mode
const creds = new IAMCredentialsStrategy();

// API Key Mode
const creds = new APIKeyCredentialsStrategy(API_KEY);

// Auth Headers Mode
const creds = new AuthHeaderCredentialsStrategy(authHeader);

const gateway = new GraphQLGateway(
  creds,
  process.env.API_API_GRAPHQLAPIENDPOINTOUTPUT
);

const myQuery = `
  query ListTodosOperation {
    listTodos {
      items {
        title
      }
    }
  }
`;

await gateway.runQuery({
  operationName: 'ListTodosOperation',
  query: myQuery,
  variables: {
    input: {}
  }
});

Commands

  • npm build - Run the typescript build

Package Sidebar

Install

npm i @crft/appsync-gateway

Weekly Downloads

79

Version

2.0.0

License

Apache-2.0

Unpacked Size

34.2 kB

Total Files

13

Last publish

Collaborators

  • sw-fp
  • re_fp
  • jgenere-fp
  • jtongus6
  • lmontanaro
  • jj_fp
  • wambosa
  • myspivey
  • aa-fp
  • taysmith92
  • hannuraina
  • jweinstein92
  • amcdnl
  • dsem
  • benturner-fp