Skip to content

Commit

Permalink
Environment expansion enhancements (#1763)
Browse files Browse the repository at this point in the history
### Environment variable expansion enhancements
([#1759](#1759))

* Environment expansions must be prefixed with `env.`. This will allow
us to add other expansion types in future.
* Change defaulting token from `:` to `:-`. For example:

  `${env.USER_NAME:Nandor}` => `${env.USER_NAME:-Nandor}`
* Failed expansions result in an error.
  
Previously expansions that failed due to missing environment variables
were silently skipped. Now they result in a configuration error. Add a
default if optional expansion is needed.

### Environment variable expansion prefixing
([#1759](#1759))

The environment variable: `APOLLO_ROUTER_CONFIG_ENV_PREFIX` can be used
to prefix environment variable lookups during configuration expansion.
This may be useful for security. This feature is undocumented and
unsupported and may change at any time.

For example: 

`APOLLO_ROUTER_CONFIG_ENV_PREFIX=MY_PREFIX`

Would cause:
`${env.FOO}` to be mapped to `${env.MY_PREFIX_FOO}` when expansion is
performed.



<!--
First, 🌠 thank you 🌠 for considering a contribution to Apollo!

Some of this information is also included in the /CONTRIBUTING.md file
at the
root of this repository.  We suggest you read it!

  https://github.com/apollographql/router/blob/HEAD/CONTRIBUTING.md

Here are some important details to keep in mind:

* ⏰ Your time is important
To save your precious time, if the contribution you are making will
take more than an hour, please make sure it has been discussed in an
        issue first. This is especially true for feature requests!

* 💡 Features
Feature requests can be created and discussed within a GitHub Issue.
Be sure to search for existing feature requests (and related issues!)
prior to opening a new request. If an existing issue covers the need,
please upvote that issue by using the 👍 emote, rather than opening a
        new issue.

* 🕷 Bug fixes
These can be created and discussed in this repository. When fixing a
bug,
please _try_ to add a test which verifies the fix. If you cannot, you
should
still submit the PR but we may still ask you (and help you!) to create a
test.

* 📖 Contribution guidelines
Follow https://github.com/apollographql/router/blob/HEAD/CONTRIBUTING.md
when submitting a pull request. Make sure existing tests still pass, and
add
        tests for all new behavior.

* ✏️ Explain your pull request
Describe the big picture of your changes here to communicate to what
        your pull request is meant to accomplish. Provide 🔗 links 🔗 to
associated issues! Documentation in the docs/ directory should be
updated
        as necessary.  Finally, a /CHANGELOG.md entry should be added.

We hope you will find this to be a positive experience! Contribution can
be
intimidating and we hope to alleviate that pain as much as possible.
Without
following these guidelines, you may be missing context that can help you
succeed
with your contribution, which is why we encourage discussion first.
Ultimately,
there is no guarantee that we will be able to merge your pull-request,
but by
following these guidelines we can try to avoid disappointment.

-->

Co-authored-by: bryn <bryn@apollographql.com>
  • Loading branch information
BrynCooke and bryn authored Sep 13, 2022
1 parent 9c88809 commit 4cb425d
Show file tree
Hide file tree
Showing 18 changed files with 207 additions and 301 deletions.
45 changes: 19 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ supergraph::new_from_graphql_response

By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/1746


### Environment variable expansion enhancements ([#1759](https://github.com/apollographql/router/issues/1759))

* Environment expansions must be prefixed with `env.`. This will allow us to add other expansion types in future.
* Change defaulting token from `:` to `:-`. For example:

`${env.USER_NAME:Nandor}` => `${env.USER_NAME:-Nandor}`
* Failed expansions result in an error.

Previously expansions that failed due to missing environment variables were silently skipped. Now they result in a configuration error. Add a default if optional expansion is needed.

By [@BrynCooke](https://github.com/BrynCooke) in https://github.com/apollographql/router/pull/1763

### Span client_name and client_version attributes renamed ([#1514](https://github.com/apollographql/router/issues/1514))
OpenTelemetry attributes should be grouped by `.` rather than `_`, therefore the following attributes have changed:

Expand Down Expand Up @@ -174,6 +187,19 @@ Executable::builder()
```
By [@BrynCooke](https://github.com/BrynCooke) in https://github.com/apollographql/router/pull/1734

### Environment variable expansion prefixing ([#1759](https://github.com/apollographql/router/issues/1759))

The environment variable: `APOLLO_ROUTER_CONFIG_ENV_PREFIX` can be used to prefix environment variable lookups during configuration expansion. This may be useful for security. This feature is undocumented and unsupported and may change at any time.

For example:

`APOLLO_ROUTER_CONFIG_ENV_PREFIX=MY_PREFIX`

Would cause:
`${env.FOO}` to be mapped to `${env.MY_PREFIX_FOO}` when expansion is performed.

By [@BrynCooke](https://github.com/BrynCooke) in https://github.com/apollographql/router/pull/1763

## 🐛 Fixes

### Set correctly hasNext for the last chunk of a deferred response ([#1687](https://github.com/apollographql/router/issues/1687))
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ derive_more = { version = "0.99.17", default-features = false, features = [
] }
directories = "4.0.1"
displaydoc = "0.2"
envmnt = "0.10.4"
flate2 = "1.0.24"
futures = { version = "0.3.24", features = ["thread-pool"] }
graphql_client = "0.11.0"
Expand Down Expand Up @@ -134,6 +133,7 @@ reqwest = { version = "0.11.11", default-features = false, features = [
] }
router-bridge = "0.1.6"
schemars = { version = "0.8.10", features = ["url"] }
shellexpand = "2.1.2"
sha2 = "0.10.5"
serde = { version = "1.0.144", features = ["derive", "rc"] }
serde_json_bytes = { version = "0.2.0", features = ["preserve_order"] }
Expand Down
Loading

0 comments on commit 4cb425d

Please sign in to comment.