dotansimha / dotansimha/graphql-code-generator
[cli] CLI stops handling local plugins written in TypeScript since v3.2.2
- 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
Versions before v3.2.2 takes plugins written in TypeScript. However, we bumped a few dependencies in [v3.2.2](https://github.com/dotansimha/graphql-code-generator/blob/master/packages/graphql-codegen-cli/CHANGELOG.md#322) that may have broken this feature.
Although, the examples in the doc are in `.js` and there's no mention of `.ts` support so I'm not sure if it was intentional
### Steps to Reproduce the Bug or Issue
1. Install v3.2.1: `yarn add -DE @graphql-codegen/cli@3.2.1`
2. Add the following files
```ts
// codegen.ts
import type { CodegenConfig } from "@graphql-codegen/cli";
const config: CodegenConfig = {
schema: "**/schema.graphql",
generates: {
"src/test.generated.ts": {
plugins: ["src/plugin.ts"],
},
},
};
export default config;
// src/plugin.ts
export const plugin = () => {
return "Hi from plugin!";
};
```
3. Running `graphql-codegen` creates `src/test.generated.ts` with `Hi from plugin!` as the content.
4. Change to v3.2.2: `yarn add -DE @graphql-codegen/cli@3.2.2`
5. Running `graphql-codegen` will show errors like this:
```
Unable to load template plugin matching 'src/plugin.ts'.
Reason:
Unexpected token 'export'
```
### Expected behavior
v3.2.2 and after should still take local TypeScript plugins.
### Screenshots or Videos
_No response_
### Platform
- OS: macOS
- NodeJS: 20
- `graphql` version: 16.8.0
- `@graphql-codegen/cli` version(s): 3.2.2
### Codegen Config File
_No response_
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.