Last active
April 17, 2017 18:50
-
-
Save alfondotnet/7b11190b87bd1517ffdaa4a8984c3c5d to your computer and use it in GitHub Desktop.
Dummy graphQL client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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