question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Environment variables in .graphql-let.yml

See original GitHub issue

(Follow up from #104)

In my setup I have a remote schema from a CMS together with some client only stuff that’s in a local schema definition file. To fetch the CMS schema I need to pass a fresh JWT. Iwould like to be able to set the token in an environment variable so that it doesn’t need to hard coded, nor have to create an intermediate file that graphql-let can use. Coupled with #104 and #49 this would solve the use case quite nicely.

What I have done in the past using graphql-codegen is configuring it something like this:

schema:
  - ${GRAPHQL_ENDPOINT}:
      headers:
        Authorization: Bearer ${ACCESS_TOKEN}
  - lib/type-defs.graphqls
[...]

and then passing environment variables which would then be expanded. Does/should this work using graphql-let? Perhaps I’m doing it wrong, but I’m unable to get it to work…


Bonus question: I’m using dotenv-expand to reference a .env variable within another one, something like this:

CMS_BASE_URL="https://foo.baz.bar"
GRAPHQL_ENDPOINT="${CMS_BASE_URL}/graphql"

Should/could this be supported too?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
piglovesyoucommented, Aug 19, 2020

Hi! That is definitely what we should support as codegen.yml does. I’ll check their implementation but PR is always welcome.

0reactions
piglovesyoucommented, Sep 22, 2020

@zimmicz Hi! Could you try this?

node -r dotenv/config $(yarn bin)/graphql-let

Also, supporting --require (-r) option by the graphql-let command can be worth to consider. Feel free to make a PR for the feature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Document how to use environment variables in `.yml` config file
yml ) to use graphql-codegen on a CI server. Describe the solution you'd like. Be able to pass headers in via the CLI,...
Read more >
require field - GraphQL Code Generator
This way, you can load environment variables using dotenv and use those environment variables in your .yml config file.
Read more >
Server config examples | Hasura GraphQL Docs
Examples of server configurations with Hasura GraphQL engine. ... It can be set in config.yaml or as an environment variable or as a...
Read more >
Environment variables - Prisma
An environment variable is a key value pair of string data that is stored on your machine's local environment. Refer to our Environment...
Read more >
Manage connector configuration and keys for ... - StepZen
You can use environment variables within your StepZen config.yaml file. This enables you to keep sensitive information such as API keys and DSN...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found