kikstart-graphql-client
Small NodeJS Wrapper around apollo-client that provides easy access to running queries, mutations and subscriptions.
Last updated 9 months ago by beeman .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install kikstart-graphql-client 
SYNC missed versions from official npm registry.

kikstart-graphql-client

Small NodeJS Wrapper around apollo-client that provides easy access to running queries, mutations and subscriptions.

GitHub code size in bytes GitHub repo size npm npm npm npm NPM npm GitHub last commit npm collaborators

Usage

Install dependency:

yarn add kikstart-graphql-client graphql

Import GraphQLClient:

import { GraphQLClient } from 'kikstart-graphql-client';

Create instance:

const client = new GraphQLClient({
  uri: 'http://localhost:4000/graphql',
  wsUri: 'ws://localhost:4000/graphql',
})

Run Query:

async getStatus() {
  const { data, error } = await this.client.runQuery(`
    query { status }
  `);
  if (error) {
    throw error
  }
  return data.status
}

Run Subscription:

client.runSubscription(query)
   .subscribe({
      next: res => console.log(JSON.stringify(res.data.statusSubscription, null, 2)),
      error: error => console.error(error),
      complete: () => console.log('done'),
   })
}

Credits

MIT License

Current Tags

  • 1.5.0                                ...           latest (9 months ago)

8 Versions

  • 1.5.0                                ...           9 months ago
  • 1.4.0                                ...           a year ago
  • 1.3.1                                ...           a year ago
  • 1.3.0                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependents (2)

Copyright 2014 - 2017 © taobao.org |