Skip to content

Add Fulfillment option generator function templates - #416

Open
otheriault wants to merge 6 commits into
Shopify:mainfrom
otheriault:ot.fulfillment-option-generator-templates
Open

Add Fulfillment option generator function templates#416
otheriault wants to merge 6 commits into
Shopify:mainfrom
otheriault:ot.fulfillment-option-generator-templates

Conversation

@otheriault

@otheriault otheriault commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

What

Adds new function templates for the Fulfillment option generator (cart.fulfillment-options.generate), following the established pickup-point-delivery-option-generators pattern.

Three template directories (one -js covers both vanilla JS and TypeScript via Liquid flavor switches):

  • functions-fulfillment-option-generators-rs — Rust (shopify_function 2.1.0)
  • functions-fulfillment-option-generators-js — JavaScript + TypeScript
  • functions-fulfillment-option-generators-wasm — Wasm placeholder

Registered in templates.json under the Functions group, gated behind an Experiments Platform flag via organizationExpFlags.

Targets

Mirrors the pickup-point fetch + run pattern:

  • cart.fulfillment-options.generate.fetch — returns an external HTTP request (only when the buyer's country is Canada in this demo).
  • cart.fulfillment-options.generate.run — parses the response and emits fulfillmentOptionsAdd operations, with providers/service points deduplicated into the references block.

To simulate an external API, the demo reuses the existing hosted pickup-points JSON file.

Structure parity

Each flavor matches the current pickup-point convention: schema.graphql, fetch/run input queries, the language-agnostic vitest fixture harness (tests/default.test.js + tests/fixtures/*.json), locales, and .liquid source.

Testing

Validated locally:

  • expand-liquid for rust / vanilla-js / typescript / wasm
  • Rust: cargo fmt --check, cargo clippy -- -D warnings, cargo build --release --target wasm32-unknown-unknown
  • JS/TS: graphql-codegen typegen passes (queries validate against the schema; all generated types resolve)
  • Fixtures mirror pickup-point's proven shapes 1:1

Follow-ups (out of this repo)

  • Register the template specification in the Partners repo <-- Is this still needed?
  • CDN propagation of templates.json after merge
  • Confirm ExP flag rollout for the gating handle

Add Rust, JavaScript/TypeScript, and Wasm templates for the
cart.fulfillment-options.generate function, following the established
pickup-point-delivery-option-generators pattern (optional fetch target
+ run target with external HTTP access).

- functions-fulfillment-option-generators-rs   (shopify_function 2.1.0)
- functions-fulfillment-option-generators-js    (vanilla-js + typescript)
- functions-fulfillment-option-generators-wasm
- templates.json: register under "Functions", gated by organizationExpFlags

Each flavor mirrors pickup-point structure: schema.graphql, fetch/run
input queries, the language-agnostic vitest fixture harness, and locales.

Assisted-By: devx/afb31d94-b8e2-4abe-ad93-cc5236235202
Re-sync the fulfillment-option-generator templates (rs/js/wasm) to the
current `unstable` schema dumped from shop/world, picking up the
"Remove time periods from FOG V1 function API" change plus prior drift:

- schema.graphql: copied from world's FOG dump (header normalized to
  `# api_version: unstable`). Drops the `timePeriod` field, the
  `TimePeriod`/`TimePoint` inputs, the `Duration` scalar, and the now
  unused `@oneOf` directive; renames result types to
  `CartFulfillmentOptionsGenerate{Fetch,Run}Result`; adds `Customer.createdAt`.
- rs: update run/fetch to the new result type names, drop the stale
  `time_period: None` and the orphaned `Duration` scalar alias, and
  remove `"timePeriod": null` from the README example and fixtures.
- js/ts: update the imported/returned result type names and README.

Verified: `functions-fulfillment-option-generators-rs` vitest passes
(5/5); graphql-codegen emits the new TS type names; all three schemas
are byte-identical to world below the header.

Assisted-By: devx/4b834766-2323-4549-8b8e-b7b957c22829
@otheriault
otheriault force-pushed the ot.fulfillment-option-generator-templates branch from 4a3d900 to a4a99e1 Compare August 5, 2026 12:51
The function-runner shipped with current @shopify/cli omits absent nullable
output fields rather than emitting them as null. Rust's None serializes to an
omitted key, so the expected outputs must not assert null values.

Mirrors the same alignment done for functions-discount-rs in 6ee908d. The JS
fixtures intentionally keep their nulls, since the JS template emits them
explicitly (cost: null, address2: null, ...).

Assisted-By: devx/46d23b6a-3c26-475d-9754-08333a1083b3
Pull the current unstable fulfillment option generator schema. The only change
versus the committed copy is the rename of
FulfillmentOptionsAddOperation.destinationServicePointHandle to
destinationHandle, plus the doc comments referencing it.

Updates all three flavors' schema.graphql and the code/fixtures/READMEs that
reference the field.

Assisted-By: devx/46d23b6a-3c26-475d-9754-08333a1083b3
Commit 1679dd5 swept in pnpm-lock.yaml / pnpm-workspace.yaml generated by a
local `pnpm install` across the workspace: 26 files and ~17.8k lines added to
13 unrelated Rust templates plus the repo root. None of these exist on main.

This repo deliberately does not commit lockfiles (.gitignore already lists
yarn.lock, package-lock.json and Cargo.lock); pnpm-lock.yaml was simply absent
from that list because nothing used pnpm before this branch. The generated
pnpm-workspace.yaml files were also placeholder stubs ("set this to true or
false").

Drop all of them and add both pnpm files to .gitignore so this cannot recur.

Assisted-By: devx/46d23b6a-3c26-475d-9754-08333a1083b3
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