relay-tools / react-relay-network-layer

ReactRelayNetworkLayer with middlewares and query batching for Relay Classic.
MIT License
277 stars 47 forks source link

Support max batch size #39

Closed brad-decker closed 7 years ago

brad-decker commented 7 years ago

Description of problem

Our application has a search bar that allows a user to search for items on our site. On click the search bar, relay grabs all data for the items that is searchable. When they select an item they are routed to a page that shows all items but the item that they clicked is focused (modal).

The problem is that because we are requesting more data on these items on this page, relay issues a node query for the missing data for each item (315 node queries). relay-network-layer correctly batches these together into one request but i get a 'payload too large' error (413).

Is there a way to specify a batch size so that i can avoid this issue?

nodkz commented 7 years ago

HTTP 413 Request Entity Too Large The server may reject your request in different places:


RRNL does not have the batch size option. It should be done somehow here https://github.com/nodkz/react-relay-network-layer/blob/master/src/relay/queriesBatch.js PR welcome. Sorry, I have no free time to do it myself 😔


If so many problems: on server-side, on client with batching (413) and without batching (too many requests). Anyway 315 times client, network and server generates/transmits/parses quite huge queries - too much wasted work.

I think better to use one of this solutions:

brad-decker commented 7 years ago

@nodkz Thanks for such a detailed response and all the solutions you've suggested. I think i might take a stab at doing the batch size but until then i'll implement the primeCache call you've suggested. Really appreciate it. 👍