Open eddeee888 opened 4 months ago
@graphql-codegen/cli
Versions before v3.2.2 takes plugins written in TypeScript. However, we bumped a few dependencies in v3.2.2 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
.js
.ts
yarn add -DE @graphql-codegen/cli@3.2.1
// 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_
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 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 intentionalSteps to Reproduce the Bug or Issue
yarn add -DE @graphql-codegen/cli@3.2.1
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!"; };
Unable to load template plugin matching 'src/plugin.ts'. Reason: Unexpected token 'export'