Theme code calls Shopify. A Shopify Function is code Shopify calls: you compile it to WebAssembly, deploy it with an app, and it runs at a fixed extension point during checkout (discounts, validation, payment and delivery customization).
// The anatomy of every Function target:
export function run(input) {
// input = the result of YOUR GraphQL input query.
// Decide something, then describe it as operations.
return { operations: [] };
}
The run target is pure: no network, no database, no filesystem, no clock. Everything it knows arrives through your input query.
AI tell: fetch() inside Function code, or a webhook to 'block' a checkout. A webhook only reports what already happened.