Skip to content

Comments

[Feature] Add build.typegen_command support for non-JS Shopify Functions#6870

Open
davejcameron wants to merge 2 commits intomainfrom
functions-typegen-command-support
Open

[Feature] Add build.typegen_command support for non-JS Shopify Functions#6870
davejcameron wants to merge 2 commits intomainfrom
functions-typegen-command-support

Conversation

@davejcameron
Copy link
Contributor

WHY are these changes introduced?

Currently, typegen for Shopify Functions is hardcoded to run npm exec -- graphql-code-generator --config package.json, which only works for JavaScript functions. For other languages (Rust, Zig, C), users must bundle their typegen step inside a build.sh script alongside their actual build command. This makes it impossible to run typegen independently via shopify app function typegen for non-JS functions.

WHAT is this pull request doing?

Adds a build.typegen_command TOML field so users can specify a custom typegen command that runs both via shopify app function typegen and automatically before the build command.

Example TOML:

[build]
command = "zig build -Doptimize=ReleaseSmall"
typegen_command = "npx shopify-function-codegen --language zig"

Changes:

  • Adds typegen_command as an optional string field in the function extension schema
  • Adds typegenCommand getter on ExtensionInstance
  • Updates buildGraphqlTypes to run custom command when set, falling back to the existing JS codegen flow
  • Runs typegen automatically before the build command for both JS and non-JS functions when typegen_command is configured
  • Updates the typegen CLI command description to be language-agnostic
  • Adds tests across all affected files

How to test your changes?

  1. Run function build tests: npx vitest run packages/app/src/cli/services/function/build.test.ts
  2. Run extension build tests: npx vitest run packages/app/src/cli/services/build/extension.test.ts
  3. Run function schema tests: npx vitest run packages/app/src/cli/models/extensions/specifications/function.test.ts

To test manually with a non-JS function:

  1. Add typegen_command = "echo typegen running" under [build] in a function's TOML
  2. Run shopify app function typegen — should execute the custom command
  3. Run shopify app function build — should run typegen before the build command

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

@davejcameron davejcameron requested a review from a team as a code owner February 19, 2026 19:48
@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.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.91% 14566/18460
🟡 Branches 73.23% 7229/9871
🟡 Functions 79.09% 3706/4686
🟡 Lines 79.26% 13773/17378

Test suite run success

3783 tests passing in 1455 suites.

Report generated by 🧪jest coverage report action from 5ccee3c

@davejcameron davejcameron force-pushed the functions-typegen-command-support branch from 58d6dfa to acd9b69 Compare February 19, 2026 20:06
@shayarnett
Copy link

🎩

Before: Screenshot 2026-02-19 at 3 04 50 PM

After:
Screenshot 2026-02-19 at 3 14 10 PM

@davejcameron davejcameron force-pushed the functions-typegen-command-support branch 2 times, most recently from d1d70cd to 9cf1e5d Compare February 20, 2026 00:21
@davejcameron davejcameron requested a review from a team as a code owner February 20, 2026 00:21
@davejcameron davejcameron force-pushed the functions-typegen-command-support branch from 9cf1e5d to 40c3b83 Compare February 20, 2026 00:28
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.

4 participants