Solved

ShopifyQL returns response but wrong data

Joey_Sturgis
New Member
12 0 0

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!

Accepted Solution (1)
garyrgilbert
Shopify Partner
397 40 165

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

 

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution

View solution in original post

Replies 5 (5)

garyrgilbert
Shopify Partner
397 40 165

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

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution

Joey_Sturgis
New Member
12 0 0

I still need help with this. The other reply is invalid (the example is from the documentation so the syntax isn't an issue).

garyrgilbert
Shopify Partner
397 40 165

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

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
garyrgilbert
Shopify Partner
397 40 165

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

 

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Joey_Sturgis
New Member
12 0 0

The "needs to be a plus merchant" was the missing piece here. Thank you.