Skip to content

Commit dab506a

Browse files
authored
docs(router): replace .original_url with .default in /expressions (#7335)
1 parent 69e2f74 commit dab506a

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

packages/web/docs/src/content/router/configuration/expressions.mdx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ control‑flow. For example:
3131
if .request.headers."x-feature-toggle" == "beta" {
3232
"https://beta.example.com/graphql"
3333
} else {
34-
.original_url
34+
.default
3535
}
3636
```
3737

@@ -89,13 +89,29 @@ While not a full object, the special variable `.timestamp` yields the current UN
8989
header manipulation guide demonstrates using `.timestamp` to add a `X‑Request‑Time` header. This is
9090
useful for debugging and tracing requests.
9191

92-
### `.original_url`
92+
### `.default`
9393

9494
This variable is only available in [dynamic routing expressions](./override_subgraph_urls). It holds
9595
the default URL for the current subgraph, as declared in your supergraph schema. Because the
96-
expression must return a URL, you should always provide a fallback using `.original_url` so that
97-
requests are routed somewhere when no condition matches. The configuration reference emphasises this
98-
by showing a pattern where the expression returns `.original_url` in the `else` branch.
96+
expression must return a URL, you should always provide a fallback using `.default` so that requests
97+
are routed somewhere when no condition matches. The configuration reference emphasises this by
98+
showing a pattern where the expression returns `.default` in the `else` branch.
99+
100+
### `.default`
101+
102+
This variable is available in [dynamic routing expressions](./override_subgraph_urls) and
103+
[traffic shaping expressions](./traffic_shaping). It holds the default value for the context in
104+
which it is used:
105+
106+
- In **dynamic routing**, it holds the default URL for the current subgraph, as declared in your
107+
supergraph schema.
108+
- In **traffic shaping**, it holds the default timeout value set at the global level (available for
109+
subgraph overrides).
110+
111+
When writing expressions with conditional logic (like `if` statements), you must ensure a value is
112+
returned for all paths. You may return any valid value, but `.default` is commonly used as a
113+
fallback. This allows you to override the configuration for specific conditions while maintaining
114+
the originally assigned value for all other cases.
99115

100116
## Available functions
101117

packages/web/docs/src/content/router/configuration/override_subgraph_urls.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ decisions.
5959
Within the `expression`, you have access to two key variables:
6060

6161
- `.request`: The incoming HTTP request object, including its headers.
62-
- `.original_url`: The original subgraph URL from the supergraph schema, which should be used as a
62+
- `.default`: The original subgraph URL from the supergraph schema, which should be used as a
6363
fallback.
6464

6565
```yaml
@@ -70,6 +70,6 @@ override_subgraph_urls:
7070
if .request.headers."x-region" == "eu" {
7171
"https://reviews.eu.api/graphql"
7272
} else {
73-
.original_url
73+
.default
7474
}
7575
```

packages/web/docs/src/content/router/guides/dynamic-subgraph-routing.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ For each request, the router evaluates your expression and routes to the URL it
2222
**What you have access to:**
2323

2424
- `.request` - The incoming HTTP request (headers, method, etc.)
25-
- `.original_url` - The default URL from your supergraph schema
25+
- `.default` - The default URL from your supergraph schema
2626

2727
Simple example configuration that routes based on a runtime condition:
2828

@@ -34,7 +34,7 @@ override_subgraph_urls:
3434
if .router.headers."x-use-special-instance" == "true" {
3535
"https://special-instance.com/graphql"
3636
} else {
37-
.original_url # Always provide a fallback
37+
.default # Always provide a fallback
3838
}
3939
```
4040
@@ -61,7 +61,7 @@ override_subgraph_urls:
6161
if .request.headers."x-deploy-track" == "canary" {
6262
"https://products-canary.example.com/graphql"
6363
} else {
64-
.original_url
64+
.default
6565
}
6666
```
6767
@@ -82,7 +82,7 @@ override_subgraph_urls:
8282
if random_int(1, 100) <= 10 {
8383
"https://products-canary.example.com/graphql"
8484
} else {
85-
.original_url
85+
.default
8686
}
8787
```
8888

@@ -110,6 +110,6 @@ override_subgraph_urls:
110110
"https://reviews-ap.example.com/graphql"
111111
} else {
112112
# Default to primary region
113-
.original_url
113+
.default
114114
}
115115
```

0 commit comments

Comments
 (0)