persistgraphql icon indicating copy to clipboard operation
persistgraphql copied to clipboard

[Idea] replace json property names with ordinals to reduce bandwidth

Open dcworldwide opened this issue 6 years ago • 4 comments

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?

dcworldwide avatar Sep 19 '17 01:09 dcworldwide

Does this result in a significant reduction in bundle size post-gzipping?

Poincare avatar Sep 19 '17 07:09 Poincare

Will test tomorrow. Presumably largest benefit would be for non gzip responses

dcworldwide avatar Sep 19 '17 09:09 dcworldwide

Interesting Idea. I will give it a try on Monday.

teakesdev avatar Sep 20 '17 06:09 teakesdev

A quick and dirty test on a large json file that I had.

json size test

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..

dcworldwide avatar Sep 28 '17 05:09 dcworldwide