Describe the bug
Environment variables don't work within the .graphqlrc.yml or .graphqlrc.json config file. We have the option to pass --require dotenv/config to the codegen command, but it doesn't work because codegen will only attempt to load the config file if it was not loaded before by graphql-cli. It would be nice if the graphql-cli could also read the --require parameter to load the specified modules before loading the configuration.
To Reproduce
.env
GRAPHQL_ENDPOINT=https://myproject.mydomain.com/v1/graphql
ADMIN_SECRET=123456
.graphqlrc.json
{
"schema": [
{
"${GRAPHQL_ENDPOINT}": {
"headers": {
"ADMIN-SECRET": "${ADMIN_SECRET}"
}
}
}
],
"extensions": {
"codegen": {
"generates": {
"./build/graphql/schema.graphql": {
"plugins": [
"schema-ast"
]
}
}
}
}
}
Command line
$ graphql codegen --require dotenv/config
Result: Environment variables are loaded as undefined.
Expected behavior
Environment variables should be loaded with the correct values from the .env file.
Versions (please complete the following information):
- OS:
OS X Big Sur
graphql-cli: 4.1.0
graphql: 15.5.0
@graphql-cli/codegen: 1.17.21
@graphql-codegen/schema-ast: 1.18.1
dotenv: 8.2.0
Describe the bug
Environment variables don't work within the
.graphqlrc.ymlor.graphqlrc.jsonconfig file. We have the option to pass--require dotenv/configto the codegen command, but it doesn't work because codegen will only attempt to load the config file if it was not loaded before by graphql-cli. It would be nice if the graphql-cli could also read the--requireparameter to load the specified modules before loading the configuration.To Reproduce
.env
.graphqlrc.json
Command line
Result: Environment variables are loaded as
undefined.Expected behavior
Environment variables should be loaded with the correct values from the .env file.
Versions (please complete the following information):
OS X Big Surgraphql-cli:4.1.0graphql:15.5.0@graphql-cli/codegen:1.17.21@graphql-codegen/schema-ast:1.18.1dotenv:8.2.0