You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know that the spec is agnostic regarding serialization formats, but I felt the need to share this idea with future readers, since it relates to the JSON format.
Sometimes clients want to achieve the best possible data transfer rate, trading it for processing speed. In the realm of text-based protocols, one of the ways to achieve this is through compression. Another is through deduplication of entities. What I wish to propose is an additional approach to reducing the size of GraphQL responses, which I believe might be worth mentioning in the spec.
The idea is to elide all requested keys from the resulting object and rely on the structure of the GraphQL request to be able to interpret it. In the example presented below, the useful content of the expected response (ignoring whitespace) is composed of keys (46%), values (41%) and other characters (13%). By eliminating the keys, we achieve a reduction of 46% in plain text size and 26% in the gzipped version.
I know that the spec is agnostic regarding serialization formats, but I felt the need to share this idea with future readers, since it relates to the JSON format.
Sometimes clients want to achieve the best possible data transfer rate, trading it for processing speed. In the realm of text-based protocols, one of the ways to achieve this is through compression. Another is through deduplication of entities. What I wish to propose is an additional approach to reducing the size of GraphQL responses, which I believe might be worth mentioning in the spec.
The idea is to elide all requested keys from the resulting object and rely on the structure of the GraphQL request to be able to interpret it. In the example presented below, the useful content of the expected response (ignoring whitespace) is composed of keys (46%), values (41%) and other characters (13%). By eliminating the keys, we achieve a reduction of 46% in plain text size and 26% in the gzipped version.
Consider this GraphQL query
yielding the result (the
data
field)that can be transformed with the following
jq
filterproducing this equivalent (and less verbose) JSON
which can be transformed back with this filter:
Note the similarity between this filter and the original query.
The text was updated successfully, but these errors were encountered: