8000 Keep the GraphQL document unchanged in GET mode by hugo-vrijswijk · Pull Request #828 · gemini-hlsw/clue · GitHub
[go: up one dir, main page]

Skip to content

Keep the GraphQL document unchanged in GET mode - #828

Closed
hugo-vrijswijk wants to merge 1 commit into
mainfrom
fix/f7-get-mode-changes-query-text
Closed

hugo-vrijswijk wants to merge 1 commit into
mainfrom
fix/f7-get-mode-changes-query-text

Conversation

@hugo-vrijswijk
@hugo-vrijswijk hugo-vrijswijk commented Aug 21, 2026 •
Copy link
Copy Markdown
Contributor

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. Uses URLSearchParams to build the query parameters in the URL

@mergify mergify Bot added the scalajs label Aug 21, 2026
@mergify
mergify Bot commented Aug 21, 2026
Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@rpiaggio
Copy link
Copy Markdown
Collaborator

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.

@rpiaggio rpiaggio left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

`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.
@hugo-vrijswijk
hugo-vrijswijk force-pushed the fix/f7-get-mode-changes-query-text branch from a7e9ea7 to aeb9ada Compare August 21, 2026 14:07
@hugo-vrijswijk
Copy link
Copy Markdown
Contributor Author

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.

The better solution when running into limits is probably to use POST instead

@rpiaggio
Copy link
Copy Markdown
Collaborator

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.

According to the official GraphQL-over-HTTP specification, a server MUST accept POST requests, but it MAY accept other HTTP methods, including GET

@hugo-vrijswijk
Copy link
Copy Markdown
Contributor Author

Closing in favour of #830

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0