Skip to content

Run function GraphQL typegen with the project package manager#7265

Closed
dmerand wants to merge 2 commits into
mainfrom
dlm-graphql-codegen
Closed

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

Conversation

@dmerand

@dmerand dmerand commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

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.

dmerand commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

@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
@github-actions

Copy link
Copy Markdown
Contributor

This PR seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action.
→ If there's no activity within a week, then a bot will automatically close this.
Thanks for helping to improve Shopify's dev tooling and experience.

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.

1 participant