egraphql-fetch
Thin symmetrically encrypted GraphQL client powered by fetch
Last updated 4 years ago by leichtgewicht .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install egraphql-fetch 
SYNC missed versions from official npm registry.

graphql-fetch Build Status js-standard-style

Thin, symmetrically encrypted, GraphQL client powered by fetch.

(Based on the great work of tjmehta and compatible with graphql-fetch)

Installation

npm i --save egraphql-fetch

Usage

var fetch = require('graphql-fetch')(
  'http://domain.com/graphql',
  'keyId', //         ... ID for the key (could be user-name)
  'secretKey', //     ... Secret Key to encrypt the data (could be password)
  // cipherAlgorithm, ... Cipher algorithm used to encrypt the request (default: aes256)
  // cipherPad        ... Padding to make traffic guessing harder (defaults: 1024)
)

var query = `
  query q (id: String!) {
    user(id: $id) {
      id,
      email,
      name
    }
  }
`
var queryVars = {
  id: 'abcdef'
}
var opts = {
  // custom fetch options
}

/**
 * @param  {Query} query graphql query
 * @param  {Object} [vars]  graphql query args, optional
 * @param  {Object} [opts]  fetch options, optional
 */
fetch(query, queryVars, opts).then(function (results) {
  if (results.errors) {
    //...
    return
  }
  var user = result.data.user
  //...
})

Notes

  • Uses isomorphic-fetch under the hood, which makes fetch, Headers, Request, and Response globally available.

License

MIT

Current Tags

  • 0.2.0                                ...           latest (4 years ago)

10 Versions

  • 0.2.0                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.8                                ...           4 years ago
  • 0.0.7                                ...           4 years ago
  • 0.0.6                                ...           4 years ago
  • 0.0.5                                ...           4 years ago
  • 0.0.4                                ...           4 years ago
  • 0.0.3                                ...           4 years ago
  • 0.0.2                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (3)
Dev Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |