-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support graphql-config type #26
Comments
Ah, that's interesting! I think it's because the type for the plugin only expects a codegen config type, but doesn't also allow the more generic graphql config type. I can look into adding the option to pass a more generic graphql config as well! I'm not sure if there are consequences in doing that, but I'll try it out and see what I can find. If it works in the meantime, are you able to restructure your config so that the schema/documents are inside of the codegen config itself instead, sorta like this? Then maybe there's another way to actually set import type { CodegenConfig } from '@graphql-codegen/cli';
const codegenConfig: CodegenConfig = {
overwrite: true,
schema,
documents: [
'src/**/!(*.generated).{tsx,ts,graphql,gql}',
'!src/sdk/**/*',
'!node_modules',
],
watch: CODEGEN_WATCH === 'true',
ignoreFieldConflicts: true,
generates: {
'src/sdk/gql/types.ts': {
config: {
...config,
},
plugins: ['typescript'],
},
'src/': {
preset: 'near-operation-file',
presetConfig: {
extension: '.generated.ts',
baseTypesPath: 'sdk/gql/types.ts',
},
plugins: [
'typescript-operations',
'typed-document-node',
{
add: {
content: `/* eslint-disable */`,
},
},
],
},
},
};
export default codegenConfig; Another option may be using a dedicated file for the graphql config, and referencing that file instead in the plugin options like this: import codegen from 'vite-plugin-graphql-codegen';
codegen({ configFilePathOverride: 'path/to/graphql.config.yml' }) |
Not sure what you meant with option 1 but I'm using option 2 anyways due to some schema overrides that only works with codegen but not vscode and it works great except I have to load the config fire myself. |
I'm using this plugin with https://the-guild.dev/graphql/config/docs. although the type causes TS error, it works:
error
sample of graphql-config
The text was updated successfully, but these errors were encountered: