New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Allow custom headers when introspecting in supergraph compose
#1574
feat: Allow custom headers when introspecting in supergraph compose
#1574
Conversation
Depends on upstream changes in apollographql/federation-rs#318 Closes #615
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is looking great, thanks for the work on this - i just left one note
i really like that this is backwards compatible with older versions of federation - when folks update their version of rover they don't also need to update their composition binary, because rover is what is handling the schema resolution. by the time the config file makes its way to the plugin, the sdl is resolved inline and introspection queries don't need to be performed/different config doesn't need to be serialized/deserialized 👍🏼 |
That was part of the plan 😅. I'm pretty sure serialization won't get messed up in older versions because by default |
The cool thing about this is that it doesn't matter. Input to rover can be like this: subgraphs:
products:
routing_url: "https://products.example.com"
schema:
subgraph_url: "http://localhost:4003"
introspection_headers:
"new": "thing" but the actual YAML that gets fed to the plugin looks like this: subgraphs:
products:
routing_url: "https://products.example.com"
schema:
sdl:
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.0",
import: ["@key", "@shareable", "@tag", "@inaccessible"])
type Query {
allProducts: [ProductItf]
product(id: ID!): ProductItf
}
...... truncated so adding this feature (and potentially other ways of resolving schemas in the future) doesn't matter to pre-compiled pre-distributed composition binaries, because all they care about is |
If we're not just matching on either env var or static value, do we handle resolving multiple variables in a single string? What about nesting env vars like My idea for an algorithm right now is:
|
I think we should explicitly disallow nested configuration like that because it's a pain to handle, prone to bugs, and probably just a bad idea for someone to do. I tried doing this for the router by doing the following from first, create supergraph:
path: "/"
telemetry:
experimental_logging:
when_header:
- name: apollo-router-${env.${env.MY_ENV_VAR}}
value: my_client
headers: true
body: true get a composed schema $ rover supergraph compose --config ./supergraph.yaml --output ./supergraph.graphql download the router $ curl -sSL https://router.apollo.dev/nix/latest | sh run the router with our config file and supergraph file $ MY_ENV_VAR="CLIENT_NAME" CLIENT_NAME="client-name" ./router -s ./supergraph.graphql -c ./router.yaml --dev
... truncated logs ...
2023-04-17T20:45:44.407486Z ERROR could not expand variable: ${env.MY_ENV_VAR, environment variable not found
2023-04-17T20:45:44.408319Z INFO stopped
2023-04-17T20:45:44.410397Z ERROR no valid configuration was supplied
no valid configuration was supplied I think if we detect nesting like this we just error and say it's invalid config. |
@EverlastingBugstopper I pushed a change that implements the algorithm I mentioned above—I think detecting nesting would be as hard as resolving nesting (if we're still allowing multiple values). Maybe I am wrong though, if you can think of a simple want to handle it. |
@EverlastingBugstopper I switched this to use the same variable expansion rules as router for more consistency. Now the docs about it can just point to those 😁 . I also opened #1578 and #1579 as potential follow-ups. Left to do:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few small notes and then i think we're off to the races!
oh and would you also mind updating the top level PR comment to reflect the current state of the PR? we use "squash and merge, use the PR body for the commit body" settings on this repo |
@EverlastingBugstopper I think this is good to go now, but let me know if I missed something! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! just pushed one commit that moves the shellexpand
dep to be a workspace dep. i think we're good here 👍🏼
# [0.14.0] - 2023-04-19 > Important: 1 potentially breaking changes below, indicated by **❗ BREAKING ❗** ## ❗ BREAKING ❗ - **`rover config whoami` outputs to `stdout` instead of `stderr` and using `--format json` includes more information than success or failure - @scombat, #1560 fixes #1380** When running `rover config whoami`, the output will print to `stdout` instead of `stderr`. This may break scripts that relied on parsing the output from `stderr`. The good news is that these scripts should be easier to write because passing `--format json` to `rover config whoami` will print structured output that can be parsed with a tool like [`jq`](https://stedolan.github.io/jq/tutorial/). ## 🚀 Features - **ALlow custom headers when running introspection with `rover supergraph compose` - @dbanty, #1574 fixes #615** A new field is available in `supergraph.yaml` files that allows sending headers along with introspection. This value also supports environment variable interpolation for sensitive values like authentication tokens. - **Print a wanring when attempting to publish a subgraph with an invalid routing URL - @trevor-scheer, #1543 fixes #1477** When running `rover subgraph publish`, if the `--routing-url` you specify or the routing URL stored in GraphOS is unroutable, a warning will be printed. If you are not in CI, you will need to manually confirm the publish to continue. You can dismiss the warning by passing `--allow-invalid-routing-url`. **Note:** This warning will become a hard error in the future. ## 🐛 Fixes - **Spawn a thread to avoid a rare deadlock in `rover dev` - @EverlastingBugstopper, #1548 fixes #1544** ## 🛠 Maintenance - **Updates dependencies - @EverlastingBugstopper, #1562** `apollo-parser` 0.4 -> 0.5 `git2` 0.16 -> 0.17 `opener` 0.5 -> 0.6 `predicates` 2 -> 3 `serial_test` 1 -> 2 `toml` 0.5 -> 0.7 ~`crossterm`~ - **Use Apple Silicon in CI - @EverlastingBugstopper, #1557 fixes #1555** There should be no user facing change here, we just run builds in CI much faster. ## 📚 Documentation - **Adds Apollo CLI migration guide to Rover docs - @StephenBarlow, #1568** The (deprecated) Apollo CLI documentation and the migration guide for Rover now live in Rover's docset. - **Cleans up nomenclature and links in Rover docs - @StephenBarlow, #1571 and #1573** Rover's documentation has been updated to refer to the [new GraphOS documentation](https://www.apollographql.com/docs/graphos) along with updating some terminology. - **Mention community-maintained installation methods - @dbanty, #1542** Rover's documentation now mentions the unofficial installation methods `nix` and `brew`.
Supports the same syntax as Apollo Router for variable expansion (e.g.,
${env.MY_SECRET}
) when definingintrospection_headers
.Closes #615