summaryrefslogtreecommitdiffstats
path: root/graphcool/src/getPrice.js
diff options
context:
space:
mode:
Diffstat (limited to 'graphcool/src/getPrice.js')
-rw-r--r--graphcool/src/getPrice.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/graphcool/src/getPrice.js b/graphcool/src/getPrice.js
new file mode 100644
index 0000000..7808a85
--- /dev/null
+++ b/graphcool/src/getPrice.js
@@ -0,0 +1,26 @@
+require('isomorphic-fetch')
+
+const query = `
+query SingleItem {
+ Item(id: "cj64bs7vuuqgu0116ul5cm223") {
+ price
+ }
+}
+`;
+
+function getItem(id) {
+ return fetch('https://api.graph.cool/simple/v1/cj5xz8szs28930145gct82bdj', {
+ method: 'post',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ query }),
+ })
+}
+
+
+module.exports = function(event) {
+ getItem().then(x => x.json()).then(res => {
+ console.log(res.data.Item.price);
+ }).catch(console.log)
+}