Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including apollo-client-aws-ni with all npm packages installed. Try it out:

var apolloClientAwsNi = require("apollo-client-aws-ni")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

apollo-client-aws-ni v1.0.6

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

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

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free