Skip to content

Run function GraphQL typegen with the project package manager#7265

Draft
dmerand wants to merge 2 commits intomainfrom
dlm-graphql-codegen
Draft

Run function GraphQL typegen with the project package manager#7265
dmerand wants to merge 2 commits intomainfrom
dlm-graphql-codegen

Conversation

@dmerand
Copy link
Copy Markdown
Contributor

@dmerand dmerand commented Apr 13, 2026

What

Use the function project's package manager when running GraphQL type generation for JavaScript functions.

Why

buildGraphqlTypes was hard-coded to npm exec. That breaks function projects that use a different package manager, especially when the function lives inside a workspace and the lockfile is only present above the function directory.

How

  • add a shared cli-kit helper that maps a directory to the right binary invocation
  • use that helper when running graphql-code-generator for JS functions
  • cover npm, pnpm workspace, yarn, and bun command shapes

Testing

Create or use a JS function extension in a non-npm project and run shopify app function build. GraphQL type generation should run through that project's package manager instead of npm exec.

Copy link
Copy Markdown
Contributor Author

dmerand commented Apr 13, 2026

@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/node-package-manager.d.ts
@@ -68,6 +68,10 @@ export declare function packageManagerFromUserAgent(env?: NodeJS.ProcessEnv): Pa
  * @returns The dependency manager
  */
 export declare function getPackageManager(fromDirectory: string): Promise<PackageManager>;
+export declare function packageManagerBinaryCommandForDirectory(directory: string, binary: string, ...args: string[]): Promise<{
+    command: string;
+    args: string[];
+}>;
 interface InstallNPMDependenciesRecursivelyOptions {
     /**
      * The dependency manager to use to install the dependencies.

@dmerand dmerand changed the title GraphQL codegen Run function GraphQL typegen with the project package manager Apr 13, 2026
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