Warehouse_products query cannot be made to return anything useful

With the following query:

query {
  warehouse_products {
    data {
      edges {
        node {
          id
        }
      }
    }
  }
}

I get the response “Unexpected Error”.

{
  "errors": [
    {
      "message": "Unexpected Error",
      "operation": "warehouse_products",
      "field": "data",
      "request_id": "5f345c8250b9b763f2604ac6",
      "code": 22
    }
  ],
  "data": {
    "warehouse_products": {
      "data": null
    }
  }
}

If I try to request a few more fields, such as the quantity available (the rest of the query is the same):

node {
  id
  available
}

The error changes, and instead it tells me that there are not enough credits to perform this action. The stated cost is 3001, which is beyond the global cap, so it appears that this operation cannot be invoked.

{
  "errors": [
    {
      "code": 30,
      "message": "There are not enough credits to perfom the requested operation, which requires 3001 credits, but the are only 1001 left. In 0:02:14 minutes you will have enough credits to perform the operation",
      "operation": "warehouse_products",
      "request_id": "5f345ca681e74a69682bac6d",
      "required_credits": 3001,
      "remaining_credits": 1001,
      "time_remaining": "0:02:14 minutes"
    }
  ],
  "data": {
    "warehouse_products": null
  }
}

Obviously the error in the first example is some kind of bug, but what about the second? Is it correct behavior that we simply can’t ask the warehouse_products query for anything other than id and sku?

Hi @jfmontanaro
I apologize because that error message is not clear, but you need to specify for which warehouse you want to get the warehouse_products, and as for the second error that is because you need to specify a limit for the number of products you want to get in return, something like this:

query {
  warehouse_products(warehouse_id: "V2FyZWqqdXNlOjk0NA==") {
    data (first:100) {
      edges {
        node {
          id
          sku
        }
      }
    }
  }
}

Also, the available quantity adds an extra 30 cost to the query, because that field requires some calculations like for example checking all the purchase orders sell ahead

Please let me know if that doesn’t help.
Thanks in advance!
Tom

Hi Tomas,

Thanks, that is helpful. We don’t make use of sell-ahead on purchase orders, so I can just calculate available myself from on hand an allocated.

1 Like