shopify-functions
4
总安装量
2
周安装量
#50337
全站排名
安装命令
npx skills add https://github.com/toilahuongg/google-antigravity-kit --skill shopify-functions
Agent 安装分布
opencode
2
antigravity
2
claude-code
2
windsurf
2
gemini-cli
2
Skill 文档
Shopify Functions
Shopify Functions differ from traditional backend apps. They are compiled to WASM and run on Shopify’s infrastructure with extremely low latency. They are the successor to Shopify Scripts (Plus).
1. Concepts
- Deterministic: Same input always equals same output. No random numbers, no network calls.
- Execution Time: Strict limits (e.g., 5ms for logic).
- Languages: Rust (First-class) or JavaScript (via Javy).
2. Structure
A function consists of:
shopify.extension.toml: Configuration.input.graphql: Defines data sent to the function.src/run.rs(or.js): The logic that returns anOutput.
3. Workflow
- Generate:
shopify app generate extension --template product_discounts --name my-discount - Input Query: Modify
input.graphqlto request necessary data (Cart, Customer, etc.). - CodeGen: Run
shopify app function typegento generate types from your GraphQL query. - Logic: Implement the
runfunction. - Build:
npm run build(compiles to.wasm). - Deploy:
shopify app deploy.
4. JS Example (Product Discount)
// src/run.js
// @ts-check
/**
* @typedef {import("../generated/api").RunInput} RunInput
* @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult
*/
/**
* @param {RunInput} input
* @returns {FunctionRunResult}
*/
export function run(input) {
const targets = input.cart.lines
.filter(line => line.merchandise.product.hasAnyTag)
.map(line => ({
cartLine: {
id: line.id
}
}));
if (!targets.length) {
return {
discounts: [],
discountApplicationStrategy: "FIRST",
};
}
return {
discounts: [
{
targets,
value: {
percentage: {
value: "10.0"
}
},
message: "VIP Discount"
}
],
discountApplicationStrategy: "FIRST",
};
}
5. Configuration (GraphiQL)
You can’t console.log in WASM. Use the Shopify App Bridge helper or the locally served GraphiQL explorer to debug inputs/outputs.
Run npm run dev, then open the highlighted GraphiQL URL in the terminal.