Skip to content

Instantly share code, notes, and snippets.

@jhlosin
jhlosin / graphqlMutationWithVariables.js
Created September 5, 2018 06:33
graphql mutation query with variables
const fetch = require('node-fetch')
async _updateMinerMutation (query, variables) {
const response = await fetch(process.env.GRAPHQL_ENDPOINT, {
headers: { 'Content-Type': 'application/json' },
method: 'POST',
body: JSON.stringify({query, variables}),
}).then(res => res.json()).then(res => console.log(res));
}
const query = `mutation ($id: ID!, $stat: String, $lastUpdated: DateTime, $lastGoodHashrate: DateTime) {