How to combine graphql results and get monthly and weekly sales data

Hi, we are looking for a way to execute the same shopifyQl query that fetches monthly sales totals in the newer graphql api.

We have something like this that returns monthly sales figures:

  {
    shopifyqlQuery(query: "FROM orders SHOW sum(gross_sales) AS monthly_gross_sales GROUP BY month SINCE '2024-11-01' UNTIL '2024-11-25'") {
      __typename
      ... on TableResponse {
        tableData {
          unformattedData
          rowData
        }
      }
    }
  }

But using the newer versions of the graphql api (now that shopifyql is sunsetted), we seem to only be able to return multiple orders at a time, not grouping them.

Is there a way to do this with the newer graphql api, for example grouping these values:

{
    orders(first: 5, query: "processed_at:>=2024-11-01") {
        nodes {
            subtotalPrice
        }
    }
}
1 Like

You’ll need to perform these transformations on your own.

For this use case, I highly recommend using the Bulk Operations API to retrieve the order data you need to compute from.

Then you can perform the calculations once you have downloaded and parsed the order data.

Docs: Perform bulk operations with the GraphQL Admin API

Thank you. I did start to export basic order data to Supabase in order to parse it and get the information that way, but I would prefer to use Shopify as the data source.

As this isn’t possible, I will use bulk operations to periodically export data to Supabase.

Hi kmarham, the ShopifyQL sunset definitely left a gap for folks who relied on those built-in aggregations.

The bulk operations approach Dylan mentioned works but introduces latency and orchestration overhead. If you’re already syncing to Supabase, the good news is you can run much richer queries there than ShopifyQL ever supported. Something like:

SELECT 
  date_trunc('month', processed_at) AS month,
  SUM(subtotal_price) AS monthly_gross_sales
FROM orders
WHERE processed_at >= '2024-11-01'
GROUP BY 1
ORDER BY 1;

You get the flexibility of real SQL plus weekly, daily, or any arbitrary grouping without being constrained by what Shopify exposes. The tradeoff is keeping that data fresh.

For periodic bulk exports, one pattern that helps is running the bulk operation on a schedule (hourly or daily depending on your needs) and upserting based on order ID so you don’t duplicate. You can filter the bulk query to only pull orders updated since your last sync using updated_at:>= to reduce the payload size.

The more elegant path if you’re committed to Supabase is setting up continuous sync so your orders table stays current without batch jobs. That way your analytics queries always hit live data and you skip the bulk operation choreography entirely.

Disclosure: I’m the founder of Stacksync, which handles real-time two-way sync between Shopify and Postgres/Supabase. For analytics workflows like yours where you want to query order data with SQL aggregations, it removes the need for scheduled bulk exports.

Hope that helps with the transition.