Performance of the whole path from the server to the client can be improved by not sending duplicate data.
There's already a usable PoC, gajus/graphql-deduplicator, but it relies on the formatResponse hook, meaning the whole object is first constructed and then plucked.
Perhaps it would be better to not construct it at all, and give some standardization to this feature by making it an option of apollo.
Deduplication does help a bit but will add more time to parse the data on the client side. I would say if the response contains a lot of redundant data something like message-pack encoding or compression will make it more easier to reduce the response size.
like message-pack encoding or compression will make it more easier to reduce the response size.
Message pack is a lot more expensive than the current implementation of https://github.com/gajus/graphql-deduplicator.
Compression is not going to help much if you have a lot of duplicate objects聽鈥撀燽rowser will need to parse the entire document into many duplicate objects.
I have written an article about the design decisions behind graphql-deduplicator, https://medium.com/@gajus/reducing-graphql-response-size-by-a-lot-ff5ba9dcb60.
Real life @gajus has arrived
@gajus has added some good information here, so I'm going to close this out
@gajus has added some good information here, so I'm going to close this out
Do you have thoughts about making graphql-deduplicator part of Apollo server/ recommended extension? It gives dramatic performance boost. Extra work is needed to cover various edge cases, but it is certainly doable.
Most helpful comment
Message pack is a lot more expensive than the current implementation of https://github.com/gajus/graphql-deduplicator.
Compression is not going to help much if you have a lot of duplicate objects聽鈥撀燽rowser will need to parse the entire document into many duplicate objects.
I have written an article about the design decisions behind graphql-deduplicator, https://medium.com/@gajus/reducing-graphql-response-size-by-a-lot-ff5ba9dcb60.