Repository navigation
Serialize GraphiQL configuration safely in inline scripts - #8887
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The serializer currently causes a strict TypeScript error because JSON.stringify may return undefined.
1 open finding
What changed in this PR
Safely embeds GraphiQL query and variable values in inline scripts to prevent markup injection.
Changes:
- Adds HTML-safe JSON serialization.
- Adds rendered-page regression tests.
- Adds a patch changeset.
| File | Description |
|---|---|
server.ts |
Escapes inline-script JSON values. |
server.test.ts |
Tests markup safety and value preservation. |
.changeset/graphiql-inline-script-json.md |
Documents the user-facing fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
amcaplan
approved these changes
Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

WHY are these changes introduced?
GraphiQL embeds optional initial query and variables values into its generated page. Those values need script-context serialization so HTML-like content always remains data.
WHAT is this pull request doing?
Serialize the initial query and variables as HTML-safe JSON while preserving the values GraphiQL receives. Rendered-page regressions cover both fields and ordinary values.
This is independent of #8680, and the two changes were verified to combine without conflicts.
How to manually test your changes?
From a linked app project, run:
pnpm shopify app graphiql --store shop.myshopify.com --variables '{"id":"gid://shopify/Product/1"}'Confirm GraphiQL opens with the variables populated and can run queries normally.
Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add