Skip to content

Commit

Permalink
Implement progressive @override (#2911)
Browse files Browse the repository at this point in the history
Add new optional `label` arg to `@override` which is a `String`. Capture
label in the supergraph via the new `@join__field` arg `overrideLabel`
so these values can be used during query graph creation and query
planning.

Reviewed in two separate PRs:
#2879
#2902

---------

Co-authored-by: Sachin D. Shinde <sachin@apollographql.com>
  • Loading branch information
trevor-scheer and sachindshinde committed Jan 20, 2024
1 parent 66833fb commit 6ae4294
Show file tree
Hide file tree
Showing 20 changed files with 1,363 additions and 133 deletions.
22 changes: 22 additions & 0 deletions .changeset/empty-dodos-turn.md
@@ -0,0 +1,22 @@
---
"@apollo/query-planner": minor
"@apollo/query-graphs": minor
"@apollo/composition": minor
"@apollo/federation-internals": minor
"@apollo/subgraph": minor
"@apollo/gateway": minor
---

Implement progressive `@override` functionality

The progressive `@override` feature brings a new argument to the `@override` directive: `label: String`. When a label is added to an `@override` application, the override becomes conditional, depending on parameters provided to the query planner (a set of which labels should be overridden). Note that this feature will be supported in router for enterprise users only.

Out-of-the-box, the router will support a percentage-based use case for progressive `@override`. For example:
```graphql
type Query {
hello: String @override(from: "original", label: "percent(5)")
}
```
The above example will override the root `hello` field from the "original" subgraph 5% of the time.

More complex use cases will be supported by the router via the use of coprocessors/rhai to resolve arbitrary labels to true/false values (i.e. via a feature flag service).
1 change: 1 addition & 0 deletions .cspell/cspell-dict.txt
Expand Up @@ -190,6 +190,7 @@ Reviwed
Rhai
righ
rulesof
runtimes
samee
Sant
SATISFIABILITY
Expand Down
4 changes: 2 additions & 2 deletions composition-js/src/__tests__/compose.test.ts
Expand Up @@ -80,7 +80,7 @@ describe('composition', () => {
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE
directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean, overrideLabel: String) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
directive @join__graph(name: String!, url: String!) on ENUM_VALUE
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('composition', () => {
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE
directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean, overrideLabel: String) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
directive @join__graph(name: String!, url: String!) on ENUM_VALUE
Expand Down

0 comments on commit 6ae4294

Please sign in to comment.