Convenience wrapper for
gotto interact with GraphQL
A lightweight alternative to apollo-client and relay.
$ npm install graphql-got
const graphqlGot = require('graphql-got');
const query = `{
unicorn(name: "Foo Bar") {
id
name
}
}`;
graphqlGot('api.graphql.unicorn', {query}).then(response => {
console.log(response.body);
/*
{
unicorn: {
id: 0,
name: 'Foo Bar'
}
}
*/
});Same as got, but with some additional options below. URLs without protocol will be prepended with https://.
Required
Type: string
The query to send to GraphQL.
Type: Object
Variables to be used in your query. Read more here.
Type: string
If your query contains multiple operations, this option is required to decide which operation to run.
Type: string
If defined, an Authorization header with bearer ${TOKEN} will be sent.
MIT © Kevin Mårtensson