Skip to content

Instantly share code, notes, and snippets.

@alfondotnet
Last active April 17, 2017 18:50
Show Gist options
  • Save alfondotnet/7b11190b87bd1517ffdaa4a8984c3c5d to your computer and use it in GitHub Desktop.
Save alfondotnet/7b11190b87bd1517ffdaa4a8984c3c5d to your computer and use it in GitHub Desktop.
Dummy graphQL client
export function requestUserData({ headers, userId }) {
return fetch(`${API_URL}/graphql/queries`, {
headers: {
...headers,
'Content-Type': 'application/json',
},
method: 'POST',
body: JSON.stringify({
query: `query RequestUserDataQuery ($userId: Int) {
users (id: $userId) {
first_name
last_name
}
}`,
variables: JSON.stringify({
userId: 4,
}),
}),
}).then(res => dataFromResponse(res.data['users'])));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment