Super simple GraphQL fetch client
yarn add fetch-graphql
import fetchGraphQL from 'fetch-graphql';
const query = `
query getAllUsers {
listAllUsers {
items {
uid
}
}
}
`;
const variables = `
{
"createUser": {
"uid": "Safaiyeh"
}
}
`
const data = await fetchGraphQL(
'https://yourAPI.com/graphql',
query,
variables,
{ 'header1': 'headerValue1', ...headers }
);
Pass your API Key to x-api-key header
const headers = {
'x-api-key': '<AWS KEY HERE>'
}