JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 23
  • Score
    100M100P100Q9862F
  • License MIT

grafoo client standard transport

Package Exports

  • @grafoo/http-transport

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@grafoo/http-transport) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@grafoo/http-transport

A Simple HTTP Client for GraphQL Servers

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

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