Repository navigation
Keep the GraphQL document unchanged in GET mode - #828
hugo-vrijswijk wants to merge 1 commit into
Conversation
|
Tick the box to add this pull request to the merge queue (same as
|
|
Since URLs can have no more than 2048 characters, collapsing spaces helped invocations not to go over this limit. Maybe the solution to preserve string literals is to parse and re-render? In the meantime, this PR's implementation is better than the original one since it doesn't change the content. |
`buildGetUri` collapsed repeated spaces in the document with `replaceAll(" +", " ")`. This changed the text of string literals in the document, so the server received a different operation.
GraphQL-over-HTTP defines the `query` parameter as the string representation of the source text of the document. `encodeURIComponent` already makes the text safe for a URL, so the collapse gives no benefit.
The `trim` call stays. Whitespace around the document is an ignored token in GraphQL, and the shorter URL is an advantage.
a7e9ea7 to
aeb9ada
Compare
The better solution when running into limits is probably to use POST instead |
|
Let's switch completely to POST then. It's also the safest since servers are not required to support GET, but they must support POST.
|
|
Closing in favour of #830 |
buildGetUricollapsed repeated spaces in the document withreplaceAll(" +", " "). This changed the text of string literals in the document, so the server received a different operation.GraphQL-over-HTTP defines the
queryparameter as the string representation of the source text of the document.encodeURIComponentalready makes the text safe for a URL, so the collapse gives no benefit.The
trimcall stays. Whitespace around the document is an ignored token in GraphQL, and the shorter URL is an advantage. UsesURLSearchParamsto build the query parameters in the URL