persistgraphql
persistgraphql copied to clipboard
[Idea] replace json property names with ordinals to reduce bandwidth
Just a thought, so we already have query -> id mapping. Would it then not be possible to extend that concept to the JSON payload property names?
I.e.
{
orders: [
id: "",
customer: {...}
]
}
to
{
1: [
2: "",
3: {...}
]
}
and then have apollo restore the property names?
Does this result in a significant reduction in bundle size post-gzipping?
Will test tomorrow. Presumably largest benefit would be for non gzip responses
Interesting Idea. I will give it a try on Monday.
A quick and dirty test on a large json file that I had.
output.json is a large json array with redundant keys output.optimised.json re-names all keys from strings, into single/double character pseudo keys (as per OP)
This was a large file test, so the relative % difference is probably more relevant. Per request it's probably not too big a deal, but if your server needs to handle high throughput, this could make sense..