1.0.11 • Published 7 years ago
guel v1.0.11
Install
yarn add guel
How To
var client = require('guel')({
url: 'http://your-host/graphql',
headers: {
Authorization: 'Bearer ' + token
}
})
Polyfills
isomorphic-fetch
and Promise
var variables = {
query: "Search Query",
limit: 100,
from: 200
}
client
.query(
`
query search ($query: String, $from: Int, $limit: Int) {
search(query: $query, from: $from, limit: $limit) {
took,
totalHits,
hits {
name
}
}
}`,
variables,
function(req, res) {
if (res.status === 401) {
throw new Error("Not authorized")
}
}
)
.then(function(body) {
console.log(body)
})
.catch(function(err) {
console.log(err.message)
})