Usage
const http = json => fetch('http://yourGraphQLEndpoint.com', {
method: 'POST',
cache: 'no-store',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify(json)
});
const queue = new GraphQLMux(http, 'query', 10);
queue.graphql({
requestString: `query($user: String!) {
user(id: $user) {
name
}
}`,
variableValues: {
user: 'user'
}
})
.then(...);
queue.graphql({
requestString: `query(order: String!) {
order(id: $order) {
date
total
}
}`,
variableValues: {
order: 'order'
}
})
.then(...);