Every graphQL query starts from a root node. To see all the available root node you can use, see the Shopify documentation.
Query root
You can query as many root nodes as you want. For example, the following query requests the shop object, a few fields, and the customers connection in a single request.
1
const query =`query {
2
shop {
3
id
4
name
5
email
6
}
7
customers(first:1) {
8
edges {
9
node {
10
id
11
displayName
12
phone
13
}
14
}
15
}
16
}`;
17
const resp =await shopify.graphql(query);
18
// console.log(resp)
19
/*
20
{
21
shop: {
22
id: 'gid://shopify/Shop/xxxxx',
23
name: 'xxxx',
24
email: 'xxxx'
25
},
26
"customers": {
27
"edges": [
28
{
29
"node": {
30
"id": "gid://shopify/Customer/xxx",
31
"displayName": "xxx",
32
"phone": null
33
}
34
}
35
]
36
}
37
}
38
*/
Copied!
Fetching specific ID
You can also pass in specific ID to fetch the resource