Skip to content

Update function extension templates to API version 2026-04#394

Merged
saga-dasgupta merged 3 commits intomainfrom
sd.update_functions_api_version_2026_04
Apr 21, 2026
Merged

Update function extension templates to API version 2026-04#394
saga-dasgupta merged 3 commits intomainfrom
sd.update_functions_api_version_2026_04

Conversation

@saga-dasgupta
Copy link
Copy Markdown
Contributor

@saga-dasgupta saga-dasgupta commented Apr 20, 2026

Summary

  • Bumps api_version from 2026-01 to 2026-04 in all 30 Functions extension templates (JS / RS / Wasm variants across cart-checkout-validation, cart-transform, delivery-customization, discount, fulfillment-constraints, location-rules, order-discounts, payment-customization, product-discounts, shipping-discounts).
  • Templates pinned to unstable (discounts-allocator, pickup-point-delivery-option-generators, local-pickup-delivery-option-generators) are intentionally untouched for the version bump, but their schema.graphql files are refreshed alongside everything else.
  • Regenerates schema.graphql for every function template against the new API version.
  • Adds prerequisites: None / "prerequisites": null to the one Rust source file and one test fixture that construct ProductDiscountCandidate literals — the 2026-04 schema adds a nullable prerequisites: [ProductDiscountCandidatePrerequisite!] field, and Rust requires every struct field at init even when optional. cargo check --workspace is clean after the fix.

The helper script used to regenerate these schemas is in its own PR: #397.

CI fix: stub shopify.app.toml in .github/scripts/run-wasm-tests.sh

The Wasm test job installs @shopify/cli@latest and generates a minimal shopify.app.toml so the CLI can discover extension directories for buildFunction. Since PR #383 landed in March, the CLI's app-config validator tightened and now rejects the previous two-field stub with:

[client_id]: Required
[auth]: Required
[webhooks]: Required
[application_url]: Valid URL is required
[embedded]: Boolean is required

The script now emits a full valid app config (dummy client_id, application_url, embedded, [auth], [webhooks]) so validation passes. The values are placeholders — nothing is deployed; the toml only exists for extension discovery.

Test plan

  • cargo check --workspace passes after yarn expand-liquid rust
  • CI passes (JS / TS / Rust / Wasm workflows)
  • Spot-check a generated extension compiles and tests pass against 2026-04

@saga-dasgupta saga-dasgupta requested a review from adampetro April 20, 2026 22:04
@saga-dasgupta saga-dasgupta force-pushed the sd.update_functions_api_version_2026_04 branch 2 times, most recently from eec1ca1 to 039b191 Compare April 20, 2026 22:16
Comment thread refresh-function-schemas.sh Outdated
@saga-dasgupta saga-dasgupta requested a review from adampetro April 21, 2026 16:57
Comment thread refresh-function-schemas.sh Outdated
Comment thread refresh-function-schemas.sh Outdated
Comment on lines +108 to +112
EXT="schemagen-${ID//_/-}"
LINK="$APP_DIR/extensions/$EXT"
rm -rf "$LINK"
ln -s "$RS_DIR" "$LINK"
cleanup_list+=("$EXT")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to do this in a separate directory with symlinks instead of just doing it inline?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because shopify app function schema walks up from its cwd looking for a shopify.app.toml, then uses that linked app's client_id to make an authenticated call to the Partners API and fetch the schema for the given api_version. So it has to be run from inside a directory that sits under a real linked app, not from this templates repo. The symlink is the cheap way to satisfy that constraint: we put a pointer to the template dir under <linked-app>/extensions/schemagen-* so the CLI can discover it as a function extension of the app, without copying source files around. When schema writes back to the extension dir, we copy the result into all three flavor folders in the repo and delete the symlink. Running inline would mean either (a) treating this repo as a Shopify app (which it isn't), or (b) authenticating against a dummy app and routing the request, both of which add more machinery than a one-line ln -s.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we copy the shopify.app.toml to the root directory of this repo because it is .gitignored? Or do we consider that too potentially risky?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually what run-wasm-tests.sh does already, writing a stub shopify.app.toml at the root for test discovery. The issue is that shopify app function schema hits the Partners API, so it needs a real client_id a developer has org access to. That means each dev would do shopify app config link once inside this repo to drop their own gitignored shopify.app.toml which I think is a lot more friction than what I have in place right now. And then there's also the issue that the repo root becomes a linked Shopify app. Running something like shopify app deploy from the root would try to deploy every function template as a real extension. I like the solution I have in place more.

Comment thread refresh-function-schemas.sh Outdated
Shopify CLI now validates client_id, auth, webhooks, application_url,
and embedded even when only used to discover extension directories.
Regenerates every function template's committed schema.graphql against
the 2026-04 API version. The new schema adds a nullable
`prerequisites: [ProductDiscountCandidatePrerequisite!]` field on
ProductDiscountCandidate — added `prerequisites: None` to the Rust
struct literal in functions-discount-rs and `"prerequisites": null` to
the corresponding fixture's expectedOutput.
@saga-dasgupta saga-dasgupta force-pushed the sd.update_functions_api_version_2026_04 branch from 447fb93 to 0e5b2d7 Compare April 21, 2026 20:45
@saga-dasgupta saga-dasgupta requested a review from adampetro April 21, 2026 20:58
@adampetro
Copy link
Copy Markdown
Contributor

Can we update the description based on the removal of the script?

@saga-dasgupta
Copy link
Copy Markdown
Contributor Author

Can we update the description based on the removal of the script?

It already is updated.

@adampetro
Copy link
Copy Markdown
Contributor

It already is updated.

my bad, mixed up the shopify.app.toml comment with the schema update script but it is actually the fix for the existing script for running the wasm tests

@saga-dasgupta saga-dasgupta merged commit 4b47c0f into main Apr 21, 2026
5 checks passed
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