Tiny graphQL client library
var gql = require('nanographql')
var xhr = require('xhr')
var query = gql`
query($number_of_repos:Int!) {
viewer {
name
repositories(last: $number_of_repos) {
nodes {
name
}
}
}
}
`
var variables = { number_of_repos: 3 }
xhr('/query', { json: query(variables) }, function (err, res, body) {
if (err) throw err
if (body.errors) throw body.errors
console.log(body.data)
})
Create a new graphql query function.
Create a new query object that can be sent as application/json
to a server.