dotansimha / dotansimha/graphql-code-generator
Plugin Loader does not load from CWD
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
### Which packages are impacted by your issue?
@graphql-codegen/cli
### Describe the bug
I wanted to use the code generator with the typescript plugin, but i have a shared .graphqlrc.yml for several related projects, each of them having its own npm dependency set.
the (sample) structure is as follows:
```
project1
schema.graphql
package.json
node_modules
packages, including @graphql-codegen/tpescript and @graphql-codegen/cli
...(more projects)
.graphqlrc.yml (multi-Project)
```
now when i was running `npm run generate` from inside the project1 folder, the typescript plugin could not be loaded.
editing the CLI source to log the actual error, i saw that the CLI tried to load the plugin from the folder where the .graphqlrc.yml file was located and not from the CWD.
sample structure is provided on StackBlitz.
### Your Example Website or App
[StackBlitz](https://stackblitz.com/edit/node-wze3k1?file=folder/package.json&view=editor)
### Steps to Reproduce the Bug or Issue
1. extract zip
2. cd into 'folder'
3. npm install
4. npm run generate
5. see the cli error `Unable to find template plugin matching 'typescript'`
### Expected behavior
As a user, i expected the generation to succeed, but i am seeing the error message that the typescript plugin cannot be loaded.
### Screenshots or Videos

### Platform
- OS: Windows
- NodeJS: 18.12.1
- `graphql` version: 16.6.0
- `@graphql-codegen/*` version(s):
- cli: 3.3.1
- typescript: 3.0.4
### Codegen Config File
``` yml
projects:
folder:
schema: folder/schema.graphql
extensions:
codegen:
generates:
folder/test.ts:
plugins:
- typescript
```
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.