You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
This is meant to be a starting point for discussion. This might not be something that many people need but in my case it would be helpful. I have a few things I like to do to shape the output of Codegen and I am restricted from doing so with the current implementation.
Background
Graphql-Codegen already allows for numerous configs right out of the box, especially for Typescript. Most of the options available are designed to shape the TS output to better suit specific needs. This is done through settings in the config.yml file in the project that is using codegen. refer to official codegen docs for further info.
Possible imlpementation
In reading through the source code for codegen/plugin.ts it appears that an optional property on the arugument object for levelupViteCodegen could be used as a config object and could pass configs through to the generator. A key / value object could be provided if required with the settings desired for the output. This config object could then be spread into the 'config' or 'presetConfig' sections of the call to generate. I'm not sure if it's that simple yet so I might experiment this weekend and see if I can get it working.
Considerations
By passing configurations through, it might be possible to overwrite something that the base gQuery functionality depends on, thereby making the package useless until the config is fixed. This could also cause bugs that are very hard to chase down. This will be hard to mitigate without further testing. A possible solution would be to identify settings that should be left alone, and then programming a filter to strip those settings from the config option before passing it along to generate. Doing so would then require clear documentation on what settings are ineffective and why, so people that try to use them aren't confused and frustrated.
Typing of the inputs to levelupViteCodegen with the added config would helpful in guiding people through what can and can't be changed. @Joehoel has a PR in here that gets this started, and merging the PR should go first so it can be built on.
Lastly, does anyone else want / need this, or is it just me?
The text was updated successfully, but these errors were encountered:
This would be useful for me. The graphql server I use in my project (hasura) only allows access to the schema with a custom http header. If we could set the codegen options, this header could be specified.
This is meant to be a starting point for discussion. This might not be something that many people need but in my case it would be helpful. I have a few things I like to do to shape the output of Codegen and I am restricted from doing so with the current implementation.
Background
Graphql-Codegen already allows for numerous configs right out of the box, especially for Typescript. Most of the options available are designed to shape the TS output to better suit specific needs. This is done through settings in the config.yml file in the project that is using codegen. refer to official codegen docs for further info.
Possible imlpementation
In reading through the source code for codegen/plugin.ts it appears that an optional property on the arugument object for
levelupViteCodegen
could be used as a config object and could pass configs through to the generator. A key / value object could be provided if required with the settings desired for the output. This config object could then be spread into the 'config' or 'presetConfig' sections of the call togenerate
. I'm not sure if it's that simple yet so I might experiment this weekend and see if I can get it working.Considerations
By passing configurations through, it might be possible to overwrite something that the base gQuery functionality depends on, thereby making the package useless until the config is fixed. This could also cause bugs that are very hard to chase down. This will be hard to mitigate without further testing. A possible solution would be to identify settings that should be left alone, and then programming a filter to strip those settings from the config option before passing it along to
generate
. Doing so would then require clear documentation on what settings are ineffective and why, so people that try to use them aren't confused and frustrated.Typing of the inputs to
levelupViteCodegen
with the added config would helpful in guiding people through what can and can't be changed. @Joehoel has a PR in here that gets this started, and merging the PR should go first so it can be built on.Lastly, does anyone else want / need this, or is it just me?
The text was updated successfully, but these errors were encountered: