Shopify Flow Run Code Generator
Describe what a workflow step should work out and get the Input query, Output schema and JavaScript for Flow's Run code action.
Run code has three separate fields
- Input: a GraphQL query against the workflow's own data (what the trigger and earlier steps produced), whose result becomes your function's
inputargument. - Output: a GraphQL SDL
type Output { ... }definition. Your function must return a plain object matching it exactly, and downstream steps read it from a variable named Run code. - JavaScript:
export default function main(input) { ... }, doing the actual logic.
What it can't do
| Limit | Value |
|---|---|
| Language | ECMA2020 JavaScript only, no Node.js/CommonJS APIs, no import |
| Network | No fetch or any HTTP call |
| Randomness | No Math.random, no clock-based functions like Date.now() |
| Size | Input query and Output schema: 5,000 characters each. Code: 50,000 characters. Output + console.log: 50KB combined |
| Runtime | 5 seconds, 10MB memory |
These are real constraints, not stylistic ones: code that calls fetch or imports a module won't run. If your idea needs an API call, it needs a proper Flow app action or a webhook, not Run code.
Adding it to a workflow
- 01
Add the action
In Shopify Flow, build your trigger and conditions, then add the Run code action.
- 02
Paste the three fields
Input into the Input box, Output schema into Output, and the JavaScript into the code editor.
- 03
Test it
Use Flow's test run against a real record and check the Run code variable's returned values before turning the workflow on.
Questions people ask
Is the Input query the same as the Admin API?
No. It queries Flow's own workflow data (what the trigger and earlier steps expose), not the Shopify Admin GraphQL API directly.
Can Run code call an external API?
No, fetch and other HTTP calls aren't available inside it. For that you need an app-based Flow action or a webhook.
Why does my code fail with an import error?
Run code doesn't support import, require or any Node.js/CommonJS API. Everything the function needs has to be plain JavaScript in the same file.
What debugging output can I see?
Only console.log, shown in the workflow's run log, not console.error or console.info.
I need to query the Admin API directly instead.
Use the Shopify GraphQL query generator for that.
Related tools
Last reviewed 30 September 2026.
