Skip to content

Extract GraphiQL server to @shopify/cli-kit#7379

Merged
gonzaloriestra merged 8 commits into
mainfrom
graphiql-store/extract-to-cli-kit
Jun 12, 2026
Merged

Extract GraphiQL server to @shopify/cli-kit#7379
gonzaloriestra merged 8 commits into
mainfrom
graphiql-store/extract-to-cli-kit

Conversation

@gonzaloriestra

@gonzaloriestra gonzaloriestra commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

This prepares the GraphiQL server for reuse outside @shopify/app.

WHAT is this pull request doing?

Moves the GraphiQL server, templates, utilities, and assets into @shopify/cli-kit, updates app dev to import them from cli-kit, and keeps bundled asset resolution working.

How to test your changes?

Open GraphiQL from shopify app dev

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

gonzaloriestra commented Apr 23, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@gonzaloriestra gonzaloriestra changed the title chore: extract GraphiQL server to @shopify/cli-kit Extract GraphiQL server to @shopify/cli-kit Apr 23, 2026
@gonzaloriestra gonzaloriestra force-pushed the graphiql-store/extract-to-cli-kit branch 3 times, most recently from 31897c8 to 99ac270 Compare April 24, 2026 08:00
@github-actions

Copy link
Copy Markdown
Contributor

This PR seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action.
→ If there's no activity within a week, then a bot will automatically close this.
Thanks for helping to improve Shopify's dev tooling and experience.

@github-actions github-actions Bot closed this Jun 1, 2026
@gonzaloriestra gonzaloriestra reopened this Jun 1, 2026
@gonzaloriestra gonzaloriestra added stale-exempt If added, the PR/issue won't be closed by stale-bot and removed no-pr-activity labels Jun 1, 2026
@gonzaloriestra gonzaloriestra force-pushed the graphiql-store/extract-to-cli-kit branch from 99ac270 to 3b24a0d Compare June 1, 2026 10:38
@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label Jun 1, 2026
@gonzaloriestra gonzaloriestra force-pushed the graphiql-store/extract-to-cli-kit branch 4 times, most recently from 5664802 to 5ff0757 Compare June 4, 2026 11:03
@gonzaloriestra gonzaloriestra marked this pull request as ready for review June 4, 2026 14:07
@gonzaloriestra gonzaloriestra requested a review from a team as a code owner June 4, 2026 14:07
Comment thread bin/bundling/esbuild-plugin-graphiql-imports.js
@gonzaloriestra gonzaloriestra force-pushed the graphiql-store/extract-to-cli-kit branch from cba38ae to 319a914 Compare June 12, 2026 11:40
@gonzaloriestra gonzaloriestra added this pull request to the merge queue Jun 12, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jun 12, 2026
Move the GraphiQL HTTP proxy and its templates/assets out of @shopify/app
and into @shopify/cli-kit so other packages (notably @shopify/store) can
reuse it.

This commit is purely mechanical:
- Files moved to packages/cli-kit/src/public/node/graphiql/ and
  packages/cli-kit/assets/graphiql/.
- Imports inside the moved server now use relative paths to other cli-kit
  modules instead of cross-package @shopify/cli-kit/* imports.
- Asset resolution switched to @shopify/cli-kit/assets/graphiql/*.
- @shopify/app consumers updated to import from
  @shopify/cli-kit/node/graphiql/server.
- cli-kit package.json gains h3, @shopify/polaris, @shopify/polaris-icons,
  and react-dom (with @types/react-dom in devDependencies).

Behavior is unchanged. Existing graphiql server.test.ts and utilities.test.ts
move alongside the source.
gonzaloriestra and others added 6 commits June 12, 2026 14:17
…mands

The `store auth` and `store execute` commands each defined their own
`--store` flag inline (char `s`, `SHOPIFY_FLAG_STORE`, normalized via
`normalizeStoreFqdn`, required). Lift the shared definition into
`packages/store/src/cli/flags.ts` as `storeFlags.store` and have both
commands consume it.

Behavior-preserving except that the flag's help text is now the generic
"The myshopify.com domain of the store." (previously each command
appended its own "to authenticate against." / "to execute against."
suffix); manifest, README, and reference docs are regenerated to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gonzaloriestra gonzaloriestra force-pushed the graphiql-store/extract-to-cli-kit branch from 319a914 to ef412d3 Compare June 12, 2026 12:26
@gonzaloriestra gonzaloriestra requested a review from a team as a code owner June 12, 2026 12:26
@gonzaloriestra gonzaloriestra force-pushed the graphiql-store/extract-to-cli-kit branch from ef412d3 to 2e14951 Compare June 12, 2026 13:51
@github-actions

Copy link
Copy Markdown
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

packages/cli-kit/dist/public/node/graphiql/server.d.ts
import { Server } from 'http';
import { Writable } from 'stream';
/**
 * Derives a deterministic GraphiQL authentication key from the app's API secret and store FQDN.
 * The key is stable across dev server restarts (so browser tabs survive restarts)
 * but is not guessable without the app secret.
 *
 * @param apiSecret - The Partners app's client secret used as the HMAC key.
 * @param storeFqdn - The myshopify.com domain the GraphiQL session targets.
 * @returns A 64-character hex string suitable for use as the `?key=` query param.
 */
export declare function deriveGraphiQLKey(apiSecret: string, storeFqdn: string): string;
/**
 * Resolves the GraphiQL authentication key. Uses the explicitly provided key
 * if non-empty, otherwise derives one deterministically from the app secret.
 *
 * @param providedKey - An explicit key supplied by the caller; takes precedence when non-empty.
 * @param apiSecret - The Partners app's client secret, used to derive a stable key as a fallback.
 * @param storeFqdn - The myshopify.com domain the GraphiQL session targets.
 * @returns The resolved key.
 */
export declare function resolveGraphiQLKey(providedKey: string | undefined, apiSecret: string, storeFqdn: string): string;
interface SetupGraphiQLServerOptions {
    stdout: Writable;
    port: number;
    appName: string;
    appUrl: string;
    apiKey: string;
    apiSecret: string;
    key?: string;
    storeFqdn: string;
}
/**
 * Starts a local HTTP server that hosts the GraphiQL UI and proxies requests to the
 * Admin API for the configured store. The server uses the OAuth `client_credentials`
 * grant with the supplied `apiKey` / `apiSecret` to mint and refresh access tokens
 * on the fly.
 *
 * @param options - Configuration for the server, including the target store, the
 * Partners app credentials, and the local port to bind to.
 * @returns The underlying Node `http.Server` instance, already listening on `options.port`.
 */
export declare function setupGraphiQLServer(options: SetupGraphiQLServerOptions): Server;
export {};
packages/cli-kit/dist/public/node/graphiql/utilities.d.ts
/**
 * Filters request headers to extract only custom headers that are safe to forward.
 * Blocked headers and non-string values are excluded.
 *
 * @param headers - The raw incoming request headers.
 * @returns The subset of headers that are safe to forward to the Admin API.
 */
export declare function filterCustomHeaders(headers: {
    [key: string]: string | string[] | undefined;
}): {
    [key: string]: string;
};
packages/cli-kit/dist/public/node/graphiql/templates/graphiql.d.ts
export declare const defaultQuery: string;
interface GraphiQLTemplateOptions {
    apiVersion: string;
    apiVersions: string[];
    appName: string;
    appUrl: string;
    key: string;
    storeFqdn: string;
}
export declare function graphiqlTemplate({ apiVersion, apiVersions, appName, appUrl, key, storeFqdn, }: GraphiQLTemplateOptions): string;
export {};
packages/cli-kit/dist/public/node/graphiql/templates/unauthorized.d.ts
export declare const unauthorizedTemplate: string;

Existing type declarations

We found no diffs with existing type declarations

@gonzaloriestra gonzaloriestra added this pull request to the merge queue Jun 12, 2026
Merged via the queue into main with commit 73dd3da Jun 12, 2026
27 of 28 checks passed
@gonzaloriestra gonzaloriestra deleted the graphiql-store/extract-to-cli-kit branch June 12, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. stale-exempt If added, the PR/issue won't be closed by stale-bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants