Skip to content

Conversation

@nickwesselman
Copy link
Contributor

@nickwesselman nickwesselman commented Dec 12, 2025

Add custom HTTP header support to GraphQL operations

WHY are these changes introduced?

This PR adds the ability to include custom HTTP headers when executing GraphQL operations via the CLI, which enables more advanced API usage scenarios.

WHAT is this pull request doing?

  • Adds a new --header flag to the app execute command that accepts custom HTTP headers in "Key: Value" format
  • Allows specifying multiple headers with repeated flag usage
  • Properly parses and validates header format, trimming whitespace and handling empty values
  • Includes GraphQL response extensions (like query cost) in the output when present
  • Updates the admin API request function to accept and apply custom headers

How to test your changes?

  1. Run a GraphQL query with a custom header:

    shopify app execute --header "X-Custom-Header: value" "query { shop { name } }"
    
  2. Use multiple headers:

    shopify app execute --header "X-Header-1: value1" --header "X-Header-2: value2" "query { shop { name } }"
    
  3. Verify that response extensions appear in the output when present.

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor Author

nickwesselman commented Dec 12, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Dec 12, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
79.52% (+0.29% 🔼)
14190/17845
🟡 Branches
73.56% (+0.35% 🔼)
6960/9462
🟡 Functions
79.67% (+0.31% 🔼)
3640/4569
🟡 Lines
79.89% (+0.31% 🔼)
13414/16791
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / metafield_definitions.ts
100% 100% 100% 100%
🟢
... / metaobject_definitions.ts
100% 100% 100% 100%
🟢
... / declarative-definitions.ts
98.54% 93.18% 100% 98.51%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / execute-bulk-operation.ts
92.65% (-0.21% 🔻)
86.67% (+1.37% 🔼)
100%
93.94% (+1.21% 🔼)
🟢
... / watch-bulk-operation.ts
100%
94.74% (-5.26% 🔻)
100% 100%
🟢
... / developer-platform-client.ts
84.62%
71.43% (-2.26% 🔻)
81.82%
93.75% (+3.13% 🔼)
🟢
... / ConcurrentOutput.tsx
98.36% (-1.64% 🔻)
92% (-4% 🔻)
100%
98.33% (-1.67% 🔻)
🔴
... / environment.ts
35% (-6.67% 🔻)
41.18% (-1.68% 🔻)
40% (-10% 🔻)
36.84% (-6.64% 🔻)

Test suite run success

3561 tests passing in 1415 suites.

Report generated by 🧪jest coverage report action from 2fa99aa

@nickwesselman nickwesselman changed the base branch from bulk_operation_error_message to graphite-base/6716 December 12, 2025 19:59
@nickwesselman nickwesselman changed the base branch from graphite-base/6716 to bulk_operation_error_message December 12, 2025 20:17
@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/api/admin.d.ts
@@ -25,6 +25,10 @@ export interface AdminRequestOptions<TResult, TVariables extends Variables> {
     responseOptions?: GraphQLResponseOptions<TResult>;
     /** Custom request behaviour for retries and timeouts. */
     preferredBehaviour?: RequestModeInput;
+    /** Custom HTTP headers to include with the request. */
+    addedHeaders?: {
+        [header: string]: string;
+    };
 }
 /**
  * Executes a GraphQL query against the Admin API. Uses typed documents.
@@ -41,6 +45,14 @@ export declare function adminRequestDoc<TResult, TVariables extends Variables>(o
  * @returns - An array of supported API versions.
  */
 export declare function supportedApiVersions(session: AdminSession, preferredBehaviour?: RequestModeInput): Promise<string[]>;
+/**
+ * GraphQL query to retrieve all API versions.
+ *
+ * @param session - Shopify admin session including token and Store FQDN.
+ * @param preferredBehaviour - Custom request behaviour for retries and timeouts.
+ * @returns - An array of supported and unsupported API versions.
+ */
+export declare function fetchApiVersions(session: AdminSession, preferredBehaviour?: RequestModeInput): Promise<ApiVersion[]>;
 /**
  * Returns the Admin API URL for the given store and version.
  *
@@ -50,6 +62,10 @@ export declare function supportedApiVersions(session: AdminSession, preferredBeh
  * @returns - Admin API URL.
  */
 export declare function adminUrl(store: string, version: string | undefined, session?: AdminSession): string;
+interface ApiVersion {
+    handle: string;
+    supported: boolean;
+}
 /**
  * Executes a REST request against the Admin API.
  *
@@ -82,4 +98,5 @@ export interface RestResponse {
     headers: {
         [key: string]: string[];
     };
-}
\ No newline at end of file
+}
+export {};
\ No newline at end of file

Base automatically changed from bulk_operation_error_message to main December 12, 2025 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant