Repository navigation
Add JSON output to GraphiQL commands - #8974
Open
gonzaloriestra wants to merge 8 commits into
Open
gonzaloriestra wants to merge 8 commits into
gonzaloriestra wants to merge 8 commits into
Conversation
Contributor
Author
|
/snapit |
Contributor
|
🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm. Built from Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261022150917Caution After installing, validate the version by running |
gonzaloriestra
marked this pull request as ready for review
October 23, 2026 10:20
Contributor
Differences in type declarationsWe 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:
New type declarationspackages/cli-kit/dist/public/node/graphiql/schema.d.tsimport { type InferJsonOutputSchema } from '../json-output-schema.js';
import { zod } from '../schema.js';
/** Lifecycle records written as JSONL by the standalone GraphiQL commands. */
export declare const graphiqlJsonOutputSchema: import("../json-output-schema.js").JsonOutputSchema<zod.ZodDiscriminatedUnion<"type", [zod.ZodObject<{
type: zod.ZodLiteral<"starting">;
timestamp: zod.ZodString;
storeDomain: zod.ZodString;
}, "strict", zod.ZodTypeAny, {
type: "starting";
timestamp: string;
storeDomain: string;
}, {
type: "starting";
timestamp: string;
storeDomain: string;
}>, zod.ZodObject<{
type: zod.ZodLiteral<"ready">;
timestamp: zod.ZodString;
url: zod.ZodString;
storeDomain: zod.ZodString;
api: zod.ZodLiteral<"admin">;
apiVersion: zod.ZodNullable<zod.ZodString>;
mutationsAllowed: zod.ZodBoolean;
app: zod.ZodNullable<zod.ZodObject<{
name: zod.ZodString;
url: zod.ZodString;
}, "strict", zod.ZodTypeAny, {
name: string;
url: string;
}, {
name: string;
url: string;
}>>;
}, "strict", zod.ZodTypeAny, {
type: "ready";
url: string;
timestamp: string;
app: {
name: string;
url: string;
} | null;
api: "admin";
storeDomain: string;
apiVersion: string | null;
mutationsAllowed: boolean;
}, {
type: "ready";
url: string;
timestamp: string;
app: {
name: string;
url: string;
} | null;
api: "admin";
storeDomain: string;
apiVersion: string | null;
mutationsAllowed: boolean;
}>, zod.ZodObject<{
type: zod.ZodLiteral<"stopped">;
timestamp: zod.ZodString;
reason: zod.ZodEnum<["cancelled", "sigint", "sigterm", "sigquit"]>;
}, "strict", zod.ZodTypeAny, {
type: "stopped";
timestamp: string;
reason: "cancelled" | "sigint" | "sigterm" | "sigquit";
}, {
type: "stopped";
timestamp: string;
reason: "cancelled" | "sigint" | "sigterm" | "sigquit";
}>]>>;
type WithoutTimestamp<T> = T extends unknown ? Omit<T, 'timestamp'> : never;
type GraphiQLRecord = InferJsonOutputSchema<typeof graphiqlJsonOutputSchema>;
export type GraphiQLRecordInput = WithoutTimestamp<GraphiQLRecord>;
export {};
Existing type declarationspackages/cli-kit/dist/public/node/graphiql/server.d.ts@@ -65,6 +65,10 @@ export interface SetupGraphiQLServerOptions {
* interactive UI.
*/
protectMutations?: boolean;
+ /** Called for request failures that leave the server available for subsequent requests. */
+ onRequestError?: (message: string) => void;
+ /** Routes diagnostics through command events and leaves readiness output to the session. */
+ json?: boolean;
}
export declare const MUTATIONS_BLOCKED_MESSAGE = "Mutations are disabled. Re-run with --allow-mutations to enable mutations.";
/**
packages/cli-kit/dist/public/node/graphiql/session.d.ts@@ -22,6 +22,7 @@ export interface RunGraphiQLSessionOptions {
additionalReadyMessages?: OutputMessage[];
abortSignal?: AbortSignal;
stdout?: Writable;
+ outputFormat?: 'text' | 'json';
}
/**
* Generates a random key suitable for authenticating a single local GraphiQL session.
|
This branch has not been deployed
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?
Agents need to discover when GraphiQL is ready and follow failures and shutdown without parsing terminal output.
Fixes https://github.com/shop/issues-develop/issues/24313
Fixes https://github.com/shop/issues-develop/issues/24316
WHAT is this pull request doing?
Adds
--jsontoapp graphiqlandstore graphiql. Both share typed JSONL lifecycle records (starting,ready,stopped) and schema discovery. The ready record includes the authenticated local URL, store, API context, app context, and mutation permissions. Diagnostics use stderr; fatal failures end stdout with the standard error envelope. There is no finite success result.The shared GraphiQL session waits for the server to listen and closes active connections and aborts upstream requests on shutdown. Launcher signal delegation allows cleanup to finish before exiting. SIGINT, SIGTERM, and SIGQUIT exit with 130, 143, and 131. Existing authentication, store mutation protection, and HTTP response payloads are preserved. Browser opening remains enabled unless
--no-inputis supplied, independently of output format.Updates generated help, manifests, and command documentation. Removes both commands from the JSON output exception list.
How to manually test your changes?
pnpm shopify store graphiql --store <shop.myshopify.com> --json --no-input > /tmp/graphiql.jsonl 2> /tmp/graphiql-diagnostics.jsonl. Open theready.urlin a browser and confirm GraphiQL works. Try a mutation with the default permissions: it should remain blocked and produce a diagnostic on stderr.stoppedrecord, exit code 130, and a closed local server.pnpm shopify app graphiql --path <app-path> --store <shop.myshopify.com> --json. Confirm browser opening, the app context inready, and shutdown. Repeat without--jsonto check text output.--json-schema; authentication and server startup should not run.Checklist
minor) and added a changeset