-
Notifications
You must be signed in to change notification settings - Fork 223
Description
Describe the bug
When building Shopify Function extensions with @shopify/shopify_function@^2.0.0, the build fails with:
Cannot convert undefined or null to object
[10:16:12] Parse configuration [started]
[10:16:12] Parse configuration [failed]
[10:16:12] → Cannot convert undefined or null to object
Root Cause
The Shopify CLI runs npm exec -- graphql-code-generator --config package.json to generate GraphQL types. However, the graphql-code-generator binary from @graphql-codegen/cli (bundled in @shopify/shopify_function) is located in a nested path:
node_modules/@shopify/shopify_function/node_modules/.bin/graphql-code-generator
With npm workspaces, this binary is not hoisted to node_modules/.bin/. As a result, npm exec cannot find it locally and downloads [email protected] from npm registry (an ancient 2019 package with completely different config parsing).
The npm output shows:
npm warn exec The following package was not found and will be installed: [email protected]
To Reproduce
- Create a new Shopify app with function extensions using npm workspaces
- Run
npm run devorshopify app dev - Observe the "Cannot convert undefined or null to object" error on all function builds
Expected Behavior
The build should use the @graphql-codegen/[email protected] bundled with @shopify/shopify_function, not download an incompatible ancient version.
Workaround
Add the graphql-codegen packages as direct dependencies in the root package.json:
{
"dependencies": {
"@graphql-codegen/cli": "5.0.5",
"@graphql-codegen/typescript": "4.1.6",
"@graphql-codegen/typescript-operations": "4.6.0"
}
}This exposes the binary at node_modules/.bin/graphql-code-generator so npm exec finds it locally.
Suggested Fix
Either:
- Add these packages as peer dependencies in
@shopify/shopify_functionso they're hoisted - Change the CLI to use the full path to the binary within
@shopify/shopify_function - Use
npx --package=@graphql-codegen/cli graphql-codegeninstead ofnpm exec -- graphql-code-generator
Environment
- Shopify CLI version: 3.88.1
- Node.js version: 24.12.0
- npm version: 11.6.2
- Operating System: macOS (Darwin 25.2.0)
@shopify/shopify_functionversion: ^2.0.0