Skip to content

Serialize GraphiQL configuration safely in inline scripts - #8887

Merged
lizkenyon merged 2 commits into
mainfrom
security-graphiql-inline-json
Oct 14, 2026
Merged

lizkenyon merged 2 commits into
mainfrom
security-graphiql-inline-json

Conversation

@lizkenyon

Copy link
Copy Markdown
Contributor

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

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Oct 14, 2026
@lizkenyon
lizkenyon marked this pull request as ready for review October 14, 2026 16:07
@lizkenyon
lizkenyon requested a review from a team as a code owner October 14, 2026 16:07
Copilot AI balanced review requested due to automatic review settings October 14, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@lizkenyon
lizkenyon enabled auto-merge October 14, 2026 18:56
@lizkenyon
lizkenyon added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit bb3c6e4 Oct 14, 2026
49 of 55 checks passed
@lizkenyon
lizkenyon deleted the security-graphiql-inline-json branch October 14, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants