Import environment variables from angular to codegen.js #7092
Unanswered
enriqueteles
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I'm using the graphql-code-generator in an angular project and I'd like to be able to use the angular environments instead of the dotenv but I don't know how.
The environment file (environment.ts) is something like:
I am using a js config file instead of yml (to be easier to import) and I already tried to pass the require
ts-node/register
in the command to generate and in the config file but returns an errorCannot use import statement outside a module
.I am able to generate the types and functions (using the typescript-apollo-angular plugin and others) passing the url and apiKey directly in the config file inside the schema but right now I need to use environments variables to increase security and for "best practices".
Here is the config file that is working but needs to import the envs:
Any help is welcome 😬
Beta Was this translation helpful? Give feedback.
All reactions