3 ms·
> to obtain the "orders", the /users/:id/orders endpoint should be called Ok, but an order has an array of order lines, and each order line has sub-arrays as w
by magicalhippo 5y ago
> to obtain the "orders", the /users/:id/orders endpoint should be called
Ok, but an order has an array of order lines, and each order line has sub-arrays as well, like details of the packages it was shipped in etc.
So that might be 5-10 calls to get an order line, and for a few thousand lines we're looking at several tens of thousand calls to get a full order.
Secondly, you then make some changes and want to replace the order with the data you got. You then have to produce a delta and upload that. And those thousands of calls better be done in a transaction of sorts, otherwise you'll have big issues.
Seems easier to me to just be able to GET or PUT an entire order with all the details in one go.
- BeefWellington 5y ago> Ok, but an order has an array of order lines, and each order line has sub-arrays as well, like details of the packages it was shipped in etc. > So that might be 5-10 calls to get an order line, and for a few thousand lines we're looking at several tens of thousand calls to get a full order. You definitely need to pick and choose the granularity you offer. There's a level of normalization in data structuring that approaches absurdity and this would be a good example of an absurd case. It is however an excellent demonstration of why making overbroad "you must never do X" rules is dangerous. I think a decent test is to ask yourself the question: "How much data is here that I don't need?" In the example referenced, if I'm looking at the full order history, I probably want to see only summary/header data with the option to view the full order details, so it wouldn't make sense to return to the user potentially a hundred thousand order lines' worth of data just because they're trying to view their history. If I then want to view the /orders/:id for one specific order, at that point it does make sense to return all of the related lines, shipment details, etc.