Shopify recently announced ShopifyQL for easier accessing of analytics data. However, I’m unclear of how to actually make a ShopifyQL call. They do include an example.
JavaScript
x
33
33
1
{
2
# "FROM sales SHOW total_sales BY month SINCE -1y UNTIL today" passes a ShopifyQL query to the GraphQL query.
3
shopifyqlQuery(query: "FROM sales SHOW total_sales BY month SINCE -1y UNTIL today") {
4
__typename
5
on TableResponse {
6
tableData {
7
rowData
8
columns {
9
# Elements in the columns section describe which column properties you want to return.
10
name
11
dataType
12
displayName
13
}
14
}
15
}
16
# parseErrors specifies that you want errors returned, if there were any, and which error properties you want to return.
17
parseErrors {
18
code
19
message
20
range {
21
start {
22
line
23
character
24
}
25
end {
26
line
27
character
28
}
29
}
30
}
31
}
32
}
33
However, using the GraphiQL tool to run the query hits a number of errors:
JavaScript
1
24
24
1
{
2
"errors": [
3
{
4
"message": "Field 'shopifyqlQuery' doesn't exist on type 'QueryRoot'",
5
"locations": [
6
{
7
"line": 3,
8
"column": 3
9
}
10
],
11
"path": [
12
"query",
13
"shopifyqlQuery"
14
],
15
"extensions": {
16
"code": "undefinedField",
17
"typeName": "QueryRoot",
18
"fieldName": "shopifyqlQuery"
19
}
20
}
21
]
22
}
23
24
I also tried making an authenticated call with the example query above using my app’s Node server, but ran into the same issues.
What am I missing here?
Advertisement
Answer
Looks like it only works with the unstable version currently:
https://”+shop_name+”.myshopify.com/admin/api/unstable/graphql.json
Got a successful response with this.