Closed nickhudkins closed 3 years ago
Assuming you have these two queries:
First Route makes this query:
{ viewer { items(first: 10) { edges { node { id title } } } } }
Second Route makes this query:
{ viewer { items(first: 10) { edges { node { id title description } } } } }
with the default relay network layer, you will end up with 10 (n) node requests like so:
node(id: *id) { description }
This is bad. So, the wonderful @nodkz wrote a great network layer, that when paired with some express-js middleware, handles batching.
That's wonderful if we (the collective python graphql users) were using express-js, but alas we are not so we need to implement a solution for such.
The JS implementation can be found here:
https://github.com/nodkz/react-relay-network-layer/blob/master/src/express-middleware/graphqlBatchHTTPWrapper.js
I plan to take a first pass at this tomorrow, but figured I would share with the public in case this has been on anyone else's mind.
I took a first pass, it is terrible. it works, it has no error handling. I'll keep working on it as time permits. Feel free to follow progress here: https://github.com/nickhudkins/graphql-django-view
Assuming you have these two queries:
First Route makes this query:
Second Route makes this query:
with the default relay network layer, you will end up with 10 (n) node requests like so:
This is bad. So, the wonderful @nodkz wrote a great network layer, that when paired with some express-js middleware, handles batching.
That's wonderful if we (the collective python graphql users) were using express-js, but alas we are not so we need to implement a solution for such.
The JS implementation can be found here:
https://github.com/nodkz/react-relay-network-layer/blob/master/src/express-middleware/graphqlBatchHTTPWrapper.js
I plan to take a first pass at this tomorrow, but figured I would share with the public in case this has been on anyone else's mind.