Is your feature request related to a problem? Please describe.
graphql-codegen -r dotenv/config enables environment variables within codegen.yml. For example:
schema: ${GRAPHQL_ENDPOINT}
generates:
...
This is great. However, it is common for frameworks to utilize multiple environment files, such as .env and .env.local (see React and Vue). Unfortunately, codegen only reads from the .env file.
Describe the solution you'd like
Support .env.local, .env.[mode], and .env.[mode].local.
For example, if GRAPHQL_ENDPOINT is defined in both .env and .env.local, the local version should be loaded into codegen.yml.
Describe alternatives you've considered
Prebuild scripts to merge all environment files into a single .env, but I'd like to avoid this.
Additional context
Thanks!
You could just use dotenv -c development -- graphql-codegen
@jake-leland This worked for me..
package.json:
{
...
"scripts": {
...
"generate": "DOTENV_CONFIG_PATH=./.env.local graphql-codegen -r dotenv/config --config codegen.js",
...
}
}
As suggested by @fubhy and @cantyjeffrey , you can either use DOTENV_CONFIG_PATH or wrap the execution of graphql-codegen with dotenv cli.
Most helpful comment
@jake-leland This worked for me..
package.json: