Skip to content

Add typed JSON output to theme metafields pull - #8924

Open
gonzaloriestra wants to merge 7 commits into
gonzalo/json-theme-initfrom
gonzalo/json-theme-metafields-pull
Open

gonzaloriestra wants to merge 7 commits into
gonzalo/json-theme-initfrom
gonzalo/json-theme-metafields-pull

Conversation

@gonzaloriestra

@gonzaloriestra gonzaloriestra commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Original PR and review history: #8682.

WHY are these changes introduced?

Fixes https://github.com/shop/issues-develop/issues/23694

Metafield downloads need structured outcomes and discoverable JSON support.

WHAT is this pull request doing?

Return strict flattened definitions, absolute artifact paths and explicit success/partial/skipped/cancelled outcomes. Preserve the native owner-keyed metafields.json file, successful downloads and owner-type failures; include a minor changeset for newly added theme JSON flags.

The public output follows docs/cli/json-output.md; explicitly named environments use one {environments: [...]} object.

How to manually test your changes?

shopify theme metafields pull --store example.myshopify.com --json
shopify theme metafields pull --json-schema

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
gonzaloriestra added this pull request to stack #8925 October 15, 2026 12:34
@github-actions github-actions Bot added shopify.dev preview Area: @shopify/cli @shopify/cli package issues labels Oct 15, 2026
@gonzaloriestra gonzaloriestra changed the title gonzalo/json theme metafields pull Add typed JSON output to theme metafields pull Oct 15, 2026
@gonzaloriestra
gonzaloriestra marked this pull request as ready for review October 15, 2026 12:42
@gonzaloriestra
gonzaloriestra requested review from a team as code owners October 15, 2026 12:42
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch 2 times, most recently from ac845ab to fcea2d5 Compare October 15, 2026 13:52
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch from fcea2d5 to 256736a Compare October 15, 2026 14:10
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch 2 times, most recently from 27b71ee to b2158d7 Compare October 15, 2026 15:11

@isaacroldan isaacroldan 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.

The new JSON contract needs to expose the fetch limit.


🤖 Generated by the review-pr skill

Comment thread packages/theme/src/cli/services/metafields-pull/types.ts
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch 3 times, most recently from a5458d7 to 4e4249e Compare October 16, 2026 08:40
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch from 4e4249e to 91cb45c Compare October 16, 2026 10:37
path: resolvePath(result.path),
definitions: Object.entries(result.definitions).flatMap(([handle, definitions]) =>
definitions.map((definition) => ({
ownerType: handleToOwnerType[handle as keyof typeof handleToOwnerType],

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.

this could be just a string, to not hardcode a list of values that might change in the future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The public ownerType schema is already a string, so it accepts future upstream values. This map translates the artifact’s keys to API owner types, including variant → PRODUCTVARIANT, and also drives the fetch loop. Replacing it with the raw handle would change the output values. We only fetch the owner types listed here today.

@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch 2 times, most recently from 44684f0 to bd48699 Compare October 16, 2026 11:15
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch from bd48699 to c786ae6 Compare October 16, 2026 11:32
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/json-theme-metafields-pull branch from c786ae6 to 0d2b9d0 Compare October 16, 2026 14:20
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Potential Breaking Changes Detected

This PR contains changes that may break the existing contract.

@shopify/dev_experience — this PR contains breaking changes that require coordination for the next major release.

📦 Major Version Changesets

The following changesets request a major version bump:

Changeset Package
theme-check-json-contract.md '@shopify/cli': major
theme-preview-json-contract.md '@shopify/cli': major
theme-profile-environments.md '@shopify/cli': major

@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

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/node/base-command.d.ts
@@ -21,6 +21,7 @@ declare abstract class BaseCommand extends Command {
     static descriptionWithoutMarkdown(): string | undefined;
     static analyticsNameOverride(): string | undefined;
     static analyticsStopCommand(): string | undefined;
+    private jsonOutputFromFlags;
     catch(error: Error & {
         skipOclifErrorHandling: boolean;
     }): Promise<void>;
@@ -36,6 +37,7 @@ declare abstract class BaseCommand extends Command {
     }, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(options?: Input<TFlags, TGlobalFlags, TArgs>, argv?: string[]): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs> & {
         argv: string[];
     }>;
+    protected runWithParsedOutput<T>(flags: FlagOutput, execute: () => T): T;
     protected environmentsFilename(): string | undefined;
     protected parseEnvironmentFlags<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(environment: JsonMap, options: Input<TFlags, TGlobalFlags, TArgs>, explicitFlags: FlagOutput): Promise<FlagOutput>;
     protected validateNonTTYFlags(flags: FlagOutput): void;
packages/cli-kit/dist/cli/api/graphql/admin/generated/metafield_definitions_by_owner_type.d.ts
@@ -2,9 +2,14 @@ import * as Types from './types.js';
 import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
 export type MetafieldDefinitionsByOwnerTypeQueryVariables = Types.Exact<{
     ownerType: Types.MetafieldOwnerType;
+    after?: Types.InputMaybe<Types.Scalars['String']['input']>;
 }>;
 export type MetafieldDefinitionsByOwnerTypeQuery = {
     metafieldDefinitions: {
+        pageInfo: {
+            hasNextPage: boolean;
+            endCursor?: string | null;
+        };
         nodes: {
             key: string;
             name: string;

This branch has not been deployed

No deployments
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