question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

loader.loaderId is not a function

See original GitHub issue

Describe 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:

Additional context Reproduces with both yarn and npm.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:12
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
dotansimhacommented, Jul 28, 2021

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 😃

6reactions
dotansimhacommented, Jul 28, 2021

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 for 6.3.1. Codegen depends at the moment on ^6.3.0 so new projects that just installed codegen got 6.3.1 with the breaking change, leading to a conflict while graphql-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:

  "resolutions": {
    "@graphql-tools/prisma-loader": "6.3.0"
  }

If you are still having this issue, try to run yarn why @graphql-tools/prisma-loader and make sure it’s pinned to 6.3.0. If you got 6.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:

npm install --save-dev @graphql-tools/prisma-loader@6.3.0

If you are still having this issue, try to run npm ls @graphql-tools/prisma-loader and make sure it’s pinned to 6.3.0. If you got 6.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 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found