graphql-code-generator
graphql-code-generator copied to clipboard
`@graphql-codegen/add` only adds text to `graphql.ts`
Which packages are impacted by your issue?
@graphql-codegen/client-preset
Describe the bug
I want to add // @ts-nocheck
to all files generated by client-preset
.
However, when I use @graphql-codegen/add
, it only adds to graphql.ts
.
Your Example Website or App
https://stackblitz.com/edit/stackblitz-starters-teuxdr?file=codegen.ts
Steps to Reproduce the Bug or Issue
- Open the example above
-
npm run codegen
- Check the output in
./src/gql
-
// @ts-nocheck
is only added tographql.ts
Expected behavior
// @ts-nocheck
is added to all files generated by @graphql-codegen/client-preset
.
Screenshots or Videos
No response
Platform
- OS: StackBlitz
- NodeJS: v16.20.0
-
graphql
version: 16.7.1 -
@graphql-codegen/*
version(s):- @graphql-codegen/[email protected]
- @graphql-codegen/[email protected]
- @graphql-codegen/[email protected]
Codegen Config File
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
overwrite: true,
schema: 'https://countries.trevorblades.com/graphql',
documents: 'src/**/!(*.d).{ts,tsx}',
generates: {
'src/gql/': {
preset: 'client',
plugins: [
{
add: {
content: '// @ts-nocheck',
},
},
],
},
},
};
export default config;
Additional context
No response
I also come across this issue, does anyone know how to solve this?
any news?
Can confirm this is still a problem in "@graphql-codegen/add": "5.0.2"
.
And still a problem in "@graphql-codegen/add": "5.0.3"!
Can you share why you want to add @ts-nocheck
to each file? The client preset should not be used in combination with other plugins, if there is a need to prepend to the emitted files, we can talk about adding this!
@n1ru4l it's not only about @ts-nocheck
. It's anything we want to add. Could be //tslint ignore
.
I could add a hook, but as per the documentation:
Before adding a hook, consider the alternative of having codegen ignored in your linting. Codegen files should not be edited manually and formatting them slows down your codegen considerably. Differences can be measured in several seconds for every run on big projects.
The issue, is that it only adds it to the graphql.ts
file, and not to the fragment-masking
for example. And I don't want to tweak my ts/lint config to deal with autogenerated files.
Is there an alternative? If not I will go with a hook and a --fix
, but without having the guarantee that all errors will be auto-fixable.