A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I'm running ShopifyQL Queries through the GraphQL API on a live merchant store with the Advanced Shopify plan.
The query returns a response but the data in the response is not correct.
Query:
{shopifyqlQuery(query: "FROM orders SHOW sum(net_sales) AS monthly_net_sales GROUP BY month SINCE -1m ORDER BY month") { __typename ... on TableResponse { tableData { unformattedData rowData columns { name dataType displayName } } } parseErrors { code message range { start { line character } end { line character } } } } }
The response:
{ "data": { "shopifyqlQuery": { "__typename": "TableResponse", "tableData": { "unformattedData": [], "rowData": [], "columns": [ { "name": "month", "dataType": "month", "displayName": "Month" }, { "name": "monthly_net_sales", "dataType": "price", "displayName": "Monthly net sales" } ] }, "parseErrors": null } }, "extensions": { "cost": { "requestedQueryCost": 7, "actualQueryCost": 4, "throttleStatus": { "maximumAvailable": 1000, "currentlyAvailable": 996, "restoreRate": 50 } } } }
The store has been live since 2015 and definitely has sales.
Any help is appreciated!
Solved! Go to the solution
This is an accepted solution.
Hi Again Joey,
Just tried that query, worked like a charm.
{
"data": {
"shopifyqlQuery": {
"__typename": "TableResponse",
"tableData": {
"unformattedData": [
[
"2023-02-01T00:00:00+01:00",
18690.42
],
[
"2023-03-01T00:00:00+01:00",
14812.52
]
],
"rowData": [
[
"Feb 2023",
"€18,690.42"
],
[
"Mar 2023",
"€14,812.52"
]
],
"columns": [
{
"name": "month",
"dataType": "month",
"displayName": "Month"
},
{
"name": "monthly_net_sales",
"dataType": "price",
"displayName": "Monthly net sales"
}
]
},
"parseErrors": null
}
},
"extensions": {
"cost": {
"requestedQueryCost": 7,
"actualQueryCost": 4,
"throttleStatus": {
"maximumAvailable": 10000,
"currentlyAvailable": 9996,
"restoreRate": 500
}
}
}
}
be aware that you have to run it on a plus shop in order to get any data back since its a Plus only feature.
Cheers,
Gary
Hi there,
I don't think the graphql query parameter can be used to take sql syntax like that.
Take a look at this video tutorial on how to use the query parameter.
Cheers,
Gary
I still need help with this. The other reply is invalid (the example is from the documentation so the syntax isn't an issue).
Hi Joey,
Ok wow, this was just released in 2023-01 API, Sorry must have missed this in the changelogs. Looks promising. Will have to check it out.
In case anyone else missed it here is the link to the documentation
Cheers,
Gary
This is an accepted solution.
Hi Again Joey,
Just tried that query, worked like a charm.
{
"data": {
"shopifyqlQuery": {
"__typename": "TableResponse",
"tableData": {
"unformattedData": [
[
"2023-02-01T00:00:00+01:00",
18690.42
],
[
"2023-03-01T00:00:00+01:00",
14812.52
]
],
"rowData": [
[
"Feb 2023",
"€18,690.42"
],
[
"Mar 2023",
"€14,812.52"
]
],
"columns": [
{
"name": "month",
"dataType": "month",
"displayName": "Month"
},
{
"name": "monthly_net_sales",
"dataType": "price",
"displayName": "Monthly net sales"
}
]
},
"parseErrors": null
}
},
"extensions": {
"cost": {
"requestedQueryCost": 7,
"actualQueryCost": 4,
"throttleStatus": {
"maximumAvailable": 10000,
"currentlyAvailable": 9996,
"restoreRate": 500
}
}
}
}
be aware that you have to run it on a plus shop in order to get any data back since its a Plus only feature.
Cheers,
Gary
The "needs to be a plus merchant" was the missing piece here. Thank you.