1.0.6 • Published 6 years ago

aws-appsync-bundle v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Note

Lightweight aws-appsync without full aws-sdk.

Install

$ npm i aws-appsync-bundle --save

Usage

Ex. 

import 'isomorphic-unfetch';
import * as es6Promise from 'es6-promise';
import gql from 'graphql-tag';

// CommonJS modules
const AWSAppSyncClient = require('aws-appsync-bundle').AWSAppSyncClient;
const AUTH_TYPE = require('aws-appsync-bundle').AUTH_TYPE;

// (global as any).WebSocket = require('ws');
es6Promise.polyfill();

const client = new AWSAppSyncClient({
    url: 'https://xxxxxxxxxxxxxxxxxxxxxxxxxxx.appsync-api.us-east-1.amazonaws.com/graphql',
    region: 'us-east-1', // or whatever your region is
    auth: {
        type: AUTH_TYPE.API_KEY,
        apiKey: () => 'da2-xxxxxxxxxxxxxxxxx'
    },
    disableOffline: true
});

client.hydrated().then(function (client: any) {
    let req = {
        filter: {
            name: 'Workspace 1.elw'
        }
    };
    // Add graphQL schema request
    client.query({
        variables: req,
        query: gql`
            query x($filter: WorkspaceFilter!){
                getWorkspace(filter: $filter) {
                        items {
                            id
                            name
                            apps {
                                id
                                name
                                title
                                url
                            }
                        }
                }
        }`
    }).then((data: any) => console.log(JSON.stringify(data, undefined, 2)))
        .catch((error: any) => console.error(error));
});



## Author

**Watchara Pongsri**

+ [github/X-c0d3](https://github.com/X-c0d3/)
1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago