loader.loaderId is not a function
See original GitHub issueDescribe the bug
After upgrading from Node 14.17.3 to Node 16.5.0, the following command started failing for me:
❯ npx graphql-codegen --config codegen.yml
loader.loaderId is not a function
Although if I remove the explicit config location, it auto-detects my config and works:
❯ npx graphql-codegen
✔ Parse configuration
✔ Generate outputs
To Reproduce Steps to reproduce the behavior:
I reproduced it with the default codesandbox template:
https://codesandbox.io/s/priceless-roentgen-rc0kf?file=/package.json
yarn codegen
- Fails with reported issue ❌
yarn codegen-alt
- Works as expected ✔️
Environment:
- OS: MacOS
- “@graphql-codegen/cli”: “1.21.5”,
- “@graphql-codegen/introspection”: “^1.18.2”,
- “@graphql-codegen/typescript”: “1.22.3”,
- “@graphql-codegen/typescript-operations”: “1.18.2”,
- NodeJS: 16.x
Additional context Reproduces with both yarn and npm.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:12
- Comments:9 (4 by maintainers)
Top Results From Across the Web
TypeError: loader.loaderId is not a function #1807 - GitHub
I'm not using prisma-loader , so for me, the problem is that graphql-cli still depends on an old version of graphql-config that requires...
Read more >graphql-codegen not running with config file - Stack Overflow
In my package.json file I've got script entry that runs graphql-codegen but it complains that the --config argument is invalid: $> yarn gen ......
Read more >Name the loader-ID when using LoaderMax.parse()
Hi I need to give my loaders created from parsing an array a specific ID based on the file name. I have done...
Read more >style-loader - webpack
Allows to setup absolute path to custom function that allows to override default behavior and insert styles at any position. Warning. Do not...
Read more >LoaderOptions | loaders.gl
Option Type Default
options.fetch object or function ‑
options.nothrow boolean false
options.mimeType string ‑
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The issue seems to be related to integration with
graphql-config
and version resolution. We are working on a fix and we hope to release a hotfix with a pinned version soon 😃Background
GraphQL-Tools v8 was released a few hours ago, with many fixes, and some breaking changes. Codegen heavily depends on graphql-tools loaders to load the schema and documents.
One of the packages (
@graphql-tools/prisma-loader
) missed a version bump and got a release for6.3.1
. Codegen depends at the moment on^6.3.0
so new projects that just installed codegen got6.3.1
with the breaking change, leading to a conflict whilegraphql-config
was running.Solution
A fix was issued in this PR: https://github.com/dotansimha/graphql-code-generator/pull/6375
UPDATE: Alpha is available
@graphql-codegen/cli@1.21.8-alpha-f256bb218.0
and it seems to fix the original reproduction.UPDATE: Also deprecated
@graphql-tools/prisma-loader@6.3.1
to make sure users don’t get this version by mistake.UPDATE: Fixed in
@graphql-codegen/cli@1.21.8
Workaround:
If you are not able to upgrade to latest version of codegen, from any reason, you can still solve this issue locally.
With
yarn
If you are using Yarn, you can pin the version using resolutions, add this to your
package.json
and reinstall the dependencies:If you are still having this issue, try to run
yarn why @graphql-tools/prisma-loader
and make sure it’s pinned to6.3.0
. If you got6.3.1
- try to clear dependencies and try again.With
npm
The latest version of NPM does hoisting, you can install
@graphql-tools/prisma-loader@6.3.0
in your project this should avoid the hoisting:If you are still having this issue, try to run
npm ls @graphql-tools/prisma-loader
and make sure it’s pinned to6.3.0
. If you got6.3.1
- try to clear dependencies and try again.Next Steps
We are really excited with the new v8 release of
graphql-tools
, and we have an ongoing PR to upgrade it: https://github.com/dotansimha/graphql-code-generator/pull/6373 . For most codegen users it should change anything, maybe just some performance improvements 😃