0.4.4 • Published 3 years ago

graql v0.4.4

Weekly downloads
207
License
MIT
Repository
github
Last release
3 years ago

Coverage Status

Graql

graql is a light-weight graphql client depends on nothing but 'node-fetch'.

const {Graql} = require('graql');
const query = `
query MyGraphQuery($id: Int) {
  foobar(where: {id: {_eq: $id}}) {
    id name description
  }
}
`;
const client = new Graql('https://acme.com/graphql');
const result = await client.fetch({query, variables: {id: 1}});
console.log(result.data.foobar);

Customize fetch options

graql sets two default headers:

  • content-type: application/json
  • accept: application/json

You can add any header as you want without corrupting these default headers.

const client = new Graql(endpoint, {headers: {'x-user-agent': 'myapp'}});
client.fetch({query, variables}, {headers: {'accept': '*/*'}});

The headers set by argument to constructor is not corrupted by the argument to fetch.

Debug

If you set debug: true, then it prints out curl command to console.log.

const client = new Graql(endpoint, {debug: true});
0.4.4

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.1

4 years ago

0.1.0

4 years ago