Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Ability to configure schema registration without env vars #1216

Open
ThomWright opened this issue Aug 23, 2021 · 1 comment
Open

Ability to configure schema registration without env vars #1216

ThomWright opened this issue Aug 23, 2021 · 1 comment

Comments

@ThomWright
Copy link

Looking at these docs I see no way to configure some basic properties of schema registration using function arguments rather than environment variables.

  • APOLLO_GRAPH_ID
  • APOLLO_GRAPH_VARIANT
  • APOLLO_SERVER_USER_VERSION
  • APOLLO_SERVER_ID

If there is a way, could someone point me towards it please? If not, could it be added? Either way, could it be added to the docs?

It seems that ApolloServerPluginSchemaReporting would be the place to include (some of?) these, but I see nothing there.

Thank you.

Rant about libraries defining environment variables
I see no reason why these should be environment variables. Apollo is a library. I would like to see the configuration I pass to it in my code as function arguments, just like any other library I use. I do not want my libraries relying on global variables. As the application developer, I should get to decide what environment variables my application takes. It should not be determined by the libraries it uses.

If you're using the dotenv library, you can add the API key to the .env file in your project's root directory, like so:

This, from the linked docs, I think might encourage bad practice. Many developers might see this then add a .env file to their repo and check it in, including their secret API key. I hope I don't need to explain why this is a bad idea! In general I don't think environment variables should live in the application source code repository. See The Twelve-Factor App.

@StephenBarlow
Copy link
Contributor

Hello, thanks for reporting! You can indeed provide these values to the ApolloServer constructor via the apollo option.

You've pointed out some definite omissions in the docs (including a warning about git-ignoring .env, which we try to add anywhere we include a mention of it), so I'll leave this open until I resolve those.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants