Graphql Client
The most minimal graphql client you'll ever find
Features:
- Typescript ready: written in Typescript
- Fully tested: literally 3 functions
- Minimal footprint: 30 loc, ~800 bytes minified
- No BS cache or w/e, ask data and you shall receive
Installation
$ npm i @amoutonbrady/graphql-client
Usage
import { GraphQLClient, gql } from '@amoutonbrady/graphql-client';
const client = GraphQLClient('https://jurassic.park/graphql');
const token = getToken();
client.setAuth(`Bearer ${token}`);
client.setHeaders({ Token: token });
const query = gql`
query getDinosaur($name: String!) {
getDinosaur({ where: { name: $name } }) {
name
height
speed
}
}
`;
const variables = { name: 'Velociraptor' };
client.request(query, variables).then(console.log).catch(console.error);