apollo-client-aws-ni
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

Build Status npm version

apollo-client-aws-ni

Provides a network interface for the official Apollo client in order to allow connection to graphql server protected behind a Amazon AWS API Gateway.

Installation

npm install apollo-client-aws-ni --save

Test

npm test

Basic usage :

import { ApolloClient } from 'apollo-client';
import { AwsApiGwClient, AwsApiGwNetworkInterface } from "apollo-client-aws-ni/api-gw-connector";
declare var apigClientFactory: any; // being the AWS API GW generated SDK root object (to be imported in main html file)

var apigClient = apigClientFactory.newClient({ ... });
var clientSet = true;

const awsApiGwClient: AwsApiGwClient = {
  isAuthenticated(){
    return clientSet;
  },
  authenticationExpired(){
    clientSet = false;
  },
  graphqlPost(param, body, extra) {
    return apigClient.testPost(param, body, extra);
  }
}

const networkInterface: any = new AwsApiGwNetworkInterface(awsApiGwClient);
const client: ApolloClient = new ApolloClient({
  networkInterface: networkInterface,
});

Related blog post

https://merapar.com/2017/10/06/sending-graphql-requests-aws-api-gateway-using-apollo-client/

Related links

https://github.com/apollographql/apollo-client https://www.npmjs.com/package/apollo-client-aws-ni

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.6
    0
    • latest

Version History

Package Sidebar

Install

npm i apollo-client-aws-ni

Weekly Downloads

0

Version

1.0.6

License

ISC

Last publish

Collaborators

  • walex_merapar