When using a preset that itself has missing dependencies, the preset loading function masks the error saying that it could not find the preset when, in fact, it could not find one of the preset's dependencies.
In my case, the error being covered up is below. This is a separate issue which I haven't solved yet, but it took a fair bit of work to even discover why the @graphql-codegen/client-preset appeared to not be loading. (The underlying issue with @ardatan/relay-compiler not loading the babel deps is something I still need to resolve, so if anyone has pointers there, I'm all ears. I'll open a separate issue for that if I'm not able to resolve it today.)
As you can see from the stack, the preset loads fine, but then another dependency fails to load.
Error: Cannot find module '@babel/runtime/helpers/objectSpread2'
Require stack:
- /Users/lheywood/project-path/node_modules/@ardatan/relay-compiler/lib/transforms/SkipRedundantNodesTransform.js
- /Users/lheywood/project-path/node_modules/@graphql-tools/relay-operation-optimizer/cjs/index.js
- /Users/lheywood/project-path/node_modules/@graphql-codegen/visitor-plugin-common/cjs/optimize-operations.js
- /Users/lheywood/project-path/node_modules/@graphql-codegen/visitor-plugin-common/cjs/index.js
- /Users/lheywood/project-path/node_modules/@graphql-codegen/gql-tag-operations/cjs/index.js
- /Users/lheywood/project-path/node_modules/@graphql-codegen/client-preset/cjs/index.js
- /Users/lheywood/project-path/node_modules/@graphql-codegen/cli/cjs/codegen.js
- /Users/lheywood/project-path/node_modules/@graphql-codegen/cli/cjs/generate-and-save.js
- /Users/lheywood/project-path/node_modules/@graphql-codegen/cli/cjs/cli.js
- /Users/lheywood/project-path/node_modules/@graphql-codegen/cli/cjs/bin.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/Users/lheywood/project-path/node_modules/@ardatan/relay-compiler/lib/transforms/SkipRedundantNodesTransform.js:15:45)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/lheywood/project-path/node_modules/@ardatan/relay-compiler/lib/transforms/SkipRedundantNodesTransform.js',
'/Users/lheywood/project-path/node_modules/@graphql-tools/relay-operation-optimizer/cjs/index.js',
'/Users/lheywood/project-path/node_modules/@graphql-codegen/visitor-plugin-common/cjs/optimize-operations.js',
'/Users/lheywood/project-path/node_modules/@graphql-codegen/visitor-plugin-common/cjs/index.js',
'/Users/lheywood/project-path/node_modules/@graphql-codegen/gql-tag-operations/cjs/index.js',
'/Users/lheywood/project-path/node_modules/@graphql-codegen/client-preset/cjs/index.js',
'/Users/lheywood/project-path/node_modules/@graphql-codegen/cli/cjs/codegen.js',
'/Users/lheywood/project-path/node_modules/@graphql-codegen/cli/cjs/generate-and-save.js',
'/Users/lheywood/project-path/node_modules/@graphql-codegen/cli/cjs/cli.js',
'/Users/lheywood/project-path/node_modules/@graphql-codegen/cli/cjs/bin.js'
]
}
I expected to see an error making mention of the missing module, however because the preset loader function looks for anyMODULE_NOT_FOUND error, the displayed message is that it could not find the preset at all, not it's dependency.
Screenshots or Videos
No response
Platform
OS: macOS
NodeJS: 18.12.2
graphql version: 16.6.0
@graphql-codegen/* version(s):
@graphql-codegen/cli: ^3.3.1,
@graphql-codegen/client-preset: ^3.0.1,
Codegen Config File
import {CodegenConfig} from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
documents: ['src/**/*.tsx'],
ignoreNoDocuments: true, // for better experience with the watcher
generates: {
'./src/gql/': {
preset: 'client',
},
},
};
export default config;
Which packages are impacted by your issue?
@graphql-codegen/cli
Describe the bug
When using a preset that itself has missing dependencies, the preset loading function masks the error saying that it could not find the preset when, in fact, it could not find one of the preset's dependencies.
In my case, the error being covered up is below. This is a separate issue which I haven't solved yet, but it took a fair bit of work to even discover why the
@graphql-codegen/client-preset
appeared to not be loading. (The underlying issue with @ardatan/relay-compiler not loading the babel deps is something I still need to resolve, so if anyone has pointers there, I'm all ears. I'll open a separate issue for that if I'm not able to resolve it today.)As you can see from the stack, the preset loads fine, but then another dependency fails to load.
Your Example Website or App
https://stackblitz.com/edit/github-qesmwt?file=package.json,codegen.ts,custom/index.js
Steps to Reproduce the Bug or Issue
yarn generate
to see command failcustom/index.js
yarn generate
again to see command passExpected behavior
I expected to see an error making mention of the missing module, however because the preset loader function looks for any
MODULE_NOT_FOUND
error, the displayed message is that it could not find the preset at all, not it's dependency.Screenshots or Videos
No response
Platform
graphql
version: 16.6.0@graphql-codegen/*
version(s):@graphql-codegen/cli
: ^3.3.1,@graphql-codegen/client-preset
: ^3.0.1,Codegen Config File