My Products
Help
omelhus
PARTNER

Issue with new aggregation when not using groupBy

by omelhus

Hey,

 

I'm fetching some aggregated data, but according to the docs the _aggretate-nodes are deprecated and will be removed. The data I'm fetching does not use groupBy, and thus the new method throws an error.

 

Would simplify things if the new approach worked without grouping.

 

Works like a charm

 

query AggregatedOrderSummary($cid: Int!, $dateStart: Int!, $dateEnd: Int!) {
  useCompany(no: $cid) {
    order_aggregate(
      filter: {_and: [{orderDate: {_gte: $dateStart}}, {orderDate: {_lte: $dateEnd}}, {customerNo: {_gt: 0}}]}
    ) {
      count {
        orders: orderNo
      }
    }
  }
}

{
  "data": {
    "useCompany": {
      "order_aggregate": {
        "count": {
          "orders": 232
        }
      }
    }
  },
  "extensions": {
    "vbnxt-trace-id": "0000000000000000ac82fe3b47675fee"
  }
}

 

 

Not working

 

query AggregatedOrderSummary($cid: Int!, $dateStart: Int!, $dateEnd: Int!) {
  useCompany(no: $cid) {
    order(
      filter: {_and: [{orderDate: {_gte: $dateStart}}, {orderDate: {_lte: $dateEnd}}, {customerNo: {_gt: 0}}]}
    ) {
      items {
        aggregates {
          count {
            orders: orderNo
          }
        }
      }
    }
  }
}

{
  "errors": [
    {
      "message": "Error: SQL command no. 3010 failed.Database error.",
      "extensions": {
        "data": {
          "status": 2,
          "status_name": "DatabaseError"
        }
      }
    }
  ],
  "data": {
    "useCompany": {
      "order": {
        "items": null
      }
    }
  },
  "extensions": {
    "vbnxt-trace-id": "000000000000000075873a15a5b0ddac"
  }
}

 

 

3 REPLIES 3

by Marius Bancila
AndreasDevDotNet
CONTRIBUTOR ***

by AndreasDevDotNet

When will the old way of doing aggregate be removed ?

by Marius Bancila

Thanks for reporting it. I will investigate the problem.