@grafoo/http-transport
v1.4.2
Published
grafoo client standard transport
Readme
@grafoo/http-transport
Install
$ npm i @grafoo/http-transportUsage
@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.
