The router allows users to operate on the request headers.
all
we address all subgraph requests. Next, we can define several rules on the client’s request. The operation propagate
forwards all matching client request headers to the subgraphs. The operation set
sets a new header which is forward to the subgraphs.
The subgraphs
section allows to propagate headers for specific subgraphs. The name must match with the subgraph name in the Studio.
named
- It exactly matches on the header name.
matching
- Regex matches on the header name. You can use regex101.com to test your regexes. Go to the website and select Golang
on the left panel. Note: The Router never propagates hop-by-hop headers (such as Connection
) when propagating by regex.
negate_match
- If set to true, the result of the matching
regex will be inverted. This is useful for simulating negative lookahead behavior, which is not natively supported.
rename
: Replaces the identified header based on its name or matching criteria and transfers the value to the newly specified header.
default
: Fallback to this value when the named
, matching
or rename
header could not be found.
name
- The name of the header to set
value
- The static value to set for the header
expression
- A template expression that evaluates to the value of the header. For example: request.auth.isAuthenticated ? request.auth.claims.sub : ''
will set the header to the user’s ID if they are authenticated, otherwise an empty string.
x-my-header
to X-My-Header.
Write your rule accordingly or use (?i)``^X-Test-.*
flags to make your regex case insensitive.