-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.js
74 lines (66 loc) · 1.5 KB
/
client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const { request } = require('graphql-request')
function query() {
// let query = `{ products { name, vendor, price } }`;
let query = `{ product(code: "nokia") { name, vendor, quantity, price } } `;
request('http://localhost:3000', query).then(data => console.log(data));
}
function addNewProduct() {
let varsToBind = {
"newProduct": {
"name": "Oppo",
"code": "Oppo",
"vendor": "Oppo",
"sku": "oppo_rose",
"price": 150,
"status": "On-Stand",
"quantity": "35",
"addedBy": "basav",
"spec": {
"color": "black",
"size": "6",
"weight": 200
},
"tags": ["smart phone"]
}
}
const mutation = `mutation add($newProduct: ProductInput!) {
addNewProduct(product: $newProduct) {
name
code
vendor
sku
price
status
quantity
addedBy
spec {
color
size
weight
}
tags
}
}`;
request('http://localhost:3000', mutation, varsToBind).then(data => console.log(data));
}
function submitReview() {
let varsToBind = {
"code": "iphone",
"newReview": {
"rank": 2,
"reviewer": "Sidda",
"comments": "Bad product"
}
};
let mutation = `mutation review($code:String!, $newReview: ProductReviewInput!) {
submitReview(code:$code, review: $newReview) {
rank,
reviewer,
comments
}
}`;
request('http://localhost:3000', mutation, varsToBind).then(data => console.log(data));
}
query()
// addNewProduct();
// submitReview();