https://github.com/martinheidegger/egraphql-fetch
Symmetrically encrypted graphql fetch requests
https://github.com/martinheidegger/egraphql-fetch
Last synced: 3 months ago
JSON representation
Symmetrically encrypted graphql fetch requests
- Host: GitHub
- URL: https://github.com/martinheidegger/egraphql-fetch
- Owner: martinheidegger
- License: other
- Created: 2017-01-05T05:12:22.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-18T16:51:47.000Z (over 8 years ago)
- Last Synced: 2025-03-12T17:06:33.437Z (4 months ago)
- Language: JavaScript
- Size: 2.13 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graphql-fetch [](https://travis-ci.org/martinheidegger/egraphql-fetch) [](http://standardjs.com/)
Thin, **symmetrically encrypted**, GraphQL client powered by fetch._(Based on the great work of [tjmehta](https://github.com/tjmehta) and compatible with [graphql-fetch](https://github.com/tjmehta/graphql-fetch))_
# Installation
```bash
npm i --save egraphql-fetch
```# Usage
```js
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](https://github.com/matthew-andrews/isomorphic-fetch) under the hood, which makes `fetch`, `Headers`, `Request`, and `Response` globally available.# License
MIT