@grafoo/http-transport

grafoo client standard transport

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
@grafoo/http-transport
Minified + gzip package size for @grafoo/http-transport in KB

Readme

@grafoo/http-transport

A Simple HTTP Client for GraphQL Servers

build coverage npm downloads size code style: prettier mantained with: lerna slack

Install

$ npm i @grafoo/http-transport

Usage

@grafoo/http-transport default export is a factory that accepts as arguments uri and fetchOptions (that can be an object or a function):

import createTransport from "@grafoo/http-transport";

const request = createTransport("http://some.graphql.api", () => ({
  headers: {
    authorization: storage.getItem("authorization")
  }
}));

const USER_QUERY = `
  query($id: ID!) {
    user(id: $id) {
      name
    }
  }
`;

const variables = { id: 123 };

request(USER_QUERY, variables).then(({ data }) => {
  console.log(data.user);
});

Warning

As this package uses fetch and Object.assign under the hood, make sure to install the proper polyfills if you want to use it in your project.

LICENSE

MIT

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.