JetBrains / js-graphql-intellij-plugin

GraphQL language support for WebStorm, IntelliJ IDEA and other IDEs based on the IntelliJ Platform.
https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/
MIT License
880 stars 97 forks source link

Added the ability to load env variables from a .env file #426

Closed mellson closed 3 years ago

mellson commented 3 years ago

Thanks for creating this awesome plugin, I enjoy using it 😊 I wanted it to be able to load the env variables from a .env file so I've created this pull request which achieves just that.

Let me know if this approach is OK or too naive

mellson commented 3 years ago

Thanks for the comments @vepanimas 👍🏻 I have tried to add the improvements in the latest commit

vepanimas commented 3 years ago

@mellson thank you 👍!

Jamiewarb commented 3 years ago

Hey! Thanks so much for adding .env file support.

One thing I wanted to mention is, as a newbie to GraphQL and this plugin in PHPStorm, it took me 15-20m to figure out the actual way to use this feature. I went on a little goose chase from this issue which was how I found this thread. It was because of the space here: ${env: TOKEN} doesn't work, but ${env:TOKEN} does.

I eventually found the answer in a blog post from JetBrains

I first checked the docs here, but couldn't see how to do it. Then I checked the examples here but none of these had .env files either.

I was wondering if an example of it can be added to those examples, and/or a mention of it in the documentation.

It could just be that I'm new and this is a common convention for graphql config, but might help keep it accessible for others like me that are working with their first GraphQL API. :)

Thanks again for adding environment variable support!

mellson commented 3 years ago

Hi @Jamiewarb thanks for the feedback. It would be great if you could provide an example and send a PR.

vepanimas commented 3 years ago

I think it's a good idea to improve the docs on the main page in general, I created a dedicated issue to track progress on that. Feel free to contribute 😉 https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/issues/500