{"action":"created","issue":{"url":"https://api.github.com/repos/graphcool/graphql-config/issues/9","repository_url":"https://api.github.com/repos/graphcool/graphql-config","labels_url":"https://api.github.com/repos/graphcool/graphql-config/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/graphcool/graphql-config/issues/9/comments","events_url":"https://api.github.com/repos/graphcool/graphql-config/issues/9/events","html_url":"https://github.com/graphcool/graphql-config/issues/9","id":178031326,"number":9,"title":"Environment specific configuration","user":{"login":"fson","id":497214,"avatar_url":"https://avatars.githubusercontent.com/u/497214?v=3","gravatar_id":"","url":"https://api.github.com/users/fson","html_url":"https://github.com/fson","followers_url":"https://api.github.com/users/fson/followers","following_url":"https://api.github.com/users/fson/following{/other_user}","gists_url":"https://api.github.com/users/fson/gists{/gist_id}","starred_url":"https://api.github.com/users/fson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fson/subscriptions","organizations_url":"https://api.github.com/users/fson/orgs","repos_url":"https://api.github.com/users/fson/repos","events_url":"https://api.github.com/users/fson/events{/privacy}","received_events_url":"https://api.github.com/users/fson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-20T11:11:22Z","updated_at":"2016-09-20T16:10:09Z","closed_at":null,"body":"I think it would be important to be able to specify a different GraphQL endpoint for development and production builds of an app. For example, for development you could have a GraphQL server running locally and make a production build that uses the schema from an external production server.\r\n\r\nOut of current configuration methods, only the `GRAPHQL_ENDPOINT` environment variable supports this use case, but it doesn't allow specifying authentication credentials, so it's not ideal.\r\n\r\nThrowing in some ideas so far:\r\n\r\n* It might be possible to add something like the [env option of Babel](https://babeljs.io/docs/usage/babelrc/#env-option), e.g.:\r\n\r\n  ```\r\n  {\r\n    \"request\": {\r\n      \"url\": \"https://localhost:8080/graphql\",\r\n      \"headers\": {\r\n        \"Authorization\": \"xxxxx\"\r\n      }\r\n    }\r\n    \"env\": {\r\n      \"production\": {\r\n        \"request\": {\r\n          \"url\": \"https://api.example.com/graphql\",\r\n          \"headers\": {\r\n            \"Authorization\": \"xxxxx\"\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n  ```\r\n  However, unlike Babel, graphql-config should probably not rely on `NODE_ENV` (it's used to just distinguish between non-optimized `development` and optimized `production` build of an app, not different environments like `testing`, `staging`, etc. Also graphql-config will be useful in more than just JS apps (e.g. native mobile apps) so `NODE_ENV` doesn't make sense there.) Therefore this approach would probably require a new environment variable like `GRAPHQL_ENV`. But this method of grouping config by environment is discouraged by some recommendations like the [12-Factor App](https://12factor.net/config). (Because doesn't scale well when you need more environments.)\r\n\r\n  The approach that I personally use in my apps is to read each configuration value from a separate environment variable, so that they can be overridden for testing/staging/production environments as needed, but specify the development environment settings as defaults in the configuration file, so that the development environment can be started after checking out the project from git without any additional config.\r\n\r\n* @schickling suggested that we could include the environment in the graphqlrc filename, for example `.graphql.dev.rc`. I think this would be as good as the `env` option, but with the same drawbacks with the lack of granularity. These approaches also kind of promote storing production settings/secrets in your code repository.\r\n\r\nI think an ideal configuration might be something like the current `.graphqlrc` / `package.json` approach, but with a way to override the settings (including authentication) through an environment variable. Any ideas how this could work?"},"comment":{"url":"https://api.github.com/repos/graphcool/graphql-config/issues/comments/248350028","html_url":"https://github.com/graphcool/graphql-config/issues/9#issuecomment-248350028","issue_url":"https://api.github.com/repos/graphcool/graphql-config/issues/9","id":248350028,"user":{"login":"jimkyndemeyer","id":15837712,"avatar_url":"https://avatars.githubusercontent.com/u/15837712?v=3","gravatar_id":"","url":"https://api.github.com/users/jimkyndemeyer","html_url":"https://github.com/jimkyndemeyer","followers_url":"https://api.github.com/users/jimkyndemeyer/followers","following_url":"https://api.github.com/users/jimkyndemeyer/following{/other_user}","gists_url":"https://api.github.com/users/jimkyndemeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/jimkyndemeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimkyndemeyer/subscriptions","organizations_url":"https://api.github.com/users/jimkyndemeyer/orgs","repos_url":"https://api.github.com/users/jimkyndemeyer/repos","events_url":"https://api.github.com/users/jimkyndemeyer/events{/privacy}","received_events_url":"https://api.github.com/users/jimkyndemeyer/received_events","type":"User","site_admin":false},"created_at":"2016-09-20T16:10:09Z","updated_at":"2016-09-20T16:10:09Z","body":"Regarding `package.json`, this comes back to non-uniformity of dev environments. Not all GraphQL projects that use js-graphql-intellij-plugin are based on Node.js. Examples I've seen include Ruby, PHP, Python, Scala, and native Android development in Java.\r\n\r\nSo I suggest the config file name should be tied GraphQL and not the various technologies that leverage it.\r\n\r\n/Jim"}}
{"actor":{"display_login":"jimkyndemeyer"}}