Skip to content

Conversation

@ericlee878
Copy link
Contributor

@ericlee878 ericlee878 commented Nov 19, 2025

Resolves https://github.com/shop/issues-api-foundations/issues/1110.

Summary

Adds a new --variable-file flag to shopify app execute that allows users to provide mutation variables from a JSONL file instead of passing them inline via --variables. This makes it easier to execute bulk operations with many variables.

Implementation Details

  • New function: parseVariablesToJsonl()
    • Validates mutual exclusivity of --variables and --variable-file
    • Reads and validates file existence
    • Returns variables in JSONL format
  • Restructured data flow to use JSONL strings throughout:
    • File content is passed through as JSONL
    • Reduces unnecessary conversions (no split/rejoin for files)
  • Simplified stageFile():
    • Now accepts variablesJsonl string parameter
    • Converts directly to Buffer for upload

Testing

Create a file called variables.jsonl. This should be in the file:

{"input":{"id":"gid://shopify/Product/123","tags":["test"]}}
{"input":{"id":"gid://shopify/Product/456","tags":["test2"]}}

Run this command:

pnpm shopify app execute \
  --path <PATH_TO_APP> \
  -q 'mutation productUpdate($input: ProductInput!) { ... }' \
  --variable-file ./variables.jsonl

Copy link
Contributor Author

ericlee878 commented Nov 19, 2025

@ericlee878 ericlee878 changed the title implement-variable-file-flag Add --variable-file flag for bulk operation mutations Nov 19, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 19, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
79.22% (+0.01% 🔼)
13660/17244
🟡 Branches
73.15% (+0.06% 🔼)
6662/9107
🟡 Functions
79.33% (-0.02% 🔻)
3520/4437
🟡 Lines
79.57% (+0.01% 🔼)
12902/16214
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡
... / stage-file.ts
72.73% (-1.56% 🔻)
62.5% (+9.17% 🔼)
83.33% (-2.38% 🔻)
71.88% (-1.65% 🔻)

Test suite run success

3375 tests passing in 1380 suites.

Report generated by 🧪jest coverage report action from c6078b1

@ericlee878 ericlee878 marked this pull request as ready for review November 19, 2025 01:32
@ericlee878 ericlee878 requested a review from a team as a code owner November 19, 2025 01:32
@github-actions
Copy link
Contributor

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

@ericlee878 ericlee878 force-pushed the 11-18-implement-variable-file-flag branch from 33ff64e to 884c9f0 Compare November 19, 2025 01:46
@ericlee878 ericlee878 requested a review from a team as a code owner November 19, 2025 01:46
@ericlee878 ericlee878 force-pushed the 11-18-implement-variable-file-flag branch from 884c9f0 to 61d6550 Compare November 19, 2025 01:49
@ericlee878 ericlee878 force-pushed the 11-18-implement-variable-file-flag branch 2 times, most recently from 04238ad to f9696ab Compare November 19, 2025 21:19
@ericlee878 ericlee878 force-pushed the 11-17-malformed-graphql-operation-validation branch from ac1fd53 to 5c20695 Compare November 19, 2025 21:19
@ericlee878 ericlee878 force-pushed the 11-18-implement-variable-file-flag branch from f9696ab to 2c2b13c Compare November 19, 2025 21:23
@ericlee878 ericlee878 force-pushed the 11-17-malformed-graphql-operation-validation branch from 5c20695 to 3f00902 Compare November 19, 2025 21:23
@github-actions
Copy link
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/ui.d.ts
@@ -1,5 +1,4 @@
 import { FatalError as Fatal } from './error.js';
-import { TokenizedString } from './output.js';
 import { ConcurrentOutputProps } from '../../private/node/ui/components/ConcurrentOutput.js';
 import { handleCtrlC, render } from '../../private/node/ui.js';
 import { AlertOptions } from '../../private/node/ui/alert.js';
@@ -332,23 +331,21 @@ interface RenderTasksOptions {
  * Installing dependencies ...
  */
 export declare function renderTasks<TContext>(tasks: Task<TContext>[], { renderOptions, noProgressBar }?: RenderTasksOptions): Promise<TContext>;
-export interface RenderSingleTaskOptions<T> {
-    title: TokenizedString;
-    task: (updateStatus: (status: TokenizedString) => void) => Promise<T>;
-    renderOptions?: RenderOptions;
-}
 /**
- * Awaits a single task and displays a loading bar while it's in progress. The task's result is returned.
+ * Awaits a single promise and displays a loading bar while it's in progress. The promise's result is returned.
  * @param options - Configuration object
- * @param options.title - The initial title to display with the loading bar
- * @param options.task - The async task to execute. Receives an updateStatus callback to change the displayed title.
- * @param options.renderOptions - Optional render configuration
- * @returns The result of the task
+ * @param options.title - The title to display with the loading bar
+ * @param options.taskPromise - The promise to track
+ * @param renderOptions - Optional render configuration
+ * @returns The result of the promise
  * @example
  * ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  * Loading app ...
  */
-export declare function renderSingleTask<T>({ title, task, renderOptions }: RenderSingleTaskOptions<T>): Promise<T>;
+export declare function renderSingleTask<T>({ title, taskPromise }: {
+    title: string;
+    taskPromise: Promise<T> | (() => Promise<T>);
+}, { renderOptions }?: RenderTasksOptions): Promise<T>;
 export interface RenderTextPromptOptions extends Omit<TextPromptProps, 'onSubmit'> {
     renderOptions?: RenderOptions;
 }
packages/cli-kit/dist/private/node/ui/components/SingleTask.d.ts
@@ -1,9 +1,8 @@
-import { TokenizedString } from '../../../../public/node/output.js';
-interface SingleTaskProps<T> {
-    title: TokenizedString;
-    task: (updateStatus: (status: TokenizedString) => void) => Promise<T>;
-    onComplete?: (result: T) => void;
+import React from 'react';
+interface SingleTaskProps {
+    title: string;
+    taskPromise: Promise<unknown>;
     noColor?: boolean;
 }
-declare const SingleTask: <T>({ task, title, onComplete, noColor }: SingleTaskProps<T>) => JSX.Element | null;
+declare const SingleTask: ({ taskPromise, title, noColor }: React.PropsWithChildren<SingleTaskProps>) => JSX.Element | null;
 export { SingleTask };
\ No newline at end of file

@ericlee878 ericlee878 force-pushed the 11-17-malformed-graphql-operation-validation branch from 3f00902 to 24f0ce6 Compare November 20, 2025 17:57
@ericlee878 ericlee878 force-pushed the 11-18-implement-variable-file-flag branch 2 times, most recently from 691d000 to 204edc8 Compare November 20, 2025 18:00
@ericlee878 ericlee878 force-pushed the 11-17-malformed-graphql-operation-validation branch from 24f0ce6 to c6e18b0 Compare November 20, 2025 18:00
@ericlee878 ericlee878 force-pushed the 11-18-implement-variable-file-flag branch from 204edc8 to 028510c Compare November 20, 2025 18:24
@ericlee878 ericlee878 force-pushed the 11-18-implement-variable-file-flag branch from 028510c to c6078b1 Compare November 20, 2025 19:46
@ericlee878 ericlee878 force-pushed the 11-17-malformed-graphql-operation-validation branch from c6e18b0 to c316242 Compare November 20, 2025 19:46
Base automatically changed from 11-17-malformed-graphql-operation-validation to main November 24, 2025 17:07
@ericlee878 ericlee878 added this pull request to the merge queue Nov 24, 2025
Merged via the queue into main with commit eb6a028 Nov 24, 2025
132 of 145 checks passed
@ericlee878 ericlee878 deleted the 11-18-implement-variable-file-flag branch November 24, 2025 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants