New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

graql

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graql

Light-weight GraphQL client usging node-fetch

latest
Source
npmnpm
Version
0.4.4
Version published
Maintainers
1
Created
Source

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});

Keywords

graphql

FAQs

Package last updated on 17 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts