Closed smyrick closed 1 year ago
Subgraph URL overrides can be accomplished using the override_subgraph_url
YAML configuration, which allows overriding on a subgraph-name basis. Subgraphs which are not defined in this map will fall back to the URL in the supergraph. This should allow for most build-time overrides.
Additionally, the configuration file supports environment variable expansion if there's a need to leverage any environmental artifacts (e.g., K8s environment variables to capture a namespace search domain or something).
If more dynamic approaches are necessary, they should be possible via Rhai scripts at runtime within the subgraph_service
(e.g., by setting the request.uri
). While Rhai scripts will get run on every request, the overhead for doing a simple assignment of the URL to the uri
property.
Finally, if Rover's URL validation is at all problematic (e.g., you want to leave out the URL or have it be obviously invalid in the supergraph), the linked-to issue above was resolved by another PR and published in a recent Rover release; it's now possible to skip validation on Routing URLs if the desire exists to leave them blank using the --allow-invalid-routing-url
option.
We don't have plans to introduce any additional life-cycle hooks or customization in this realm right now, but welcome addition comments and use-cases on this issue, or in a new issue.
Is your feature request related to a problem? Please describe. My subgraph routing urls are published to GraphOS and delivered to the Router in the supergraph file. If I do not have static URLs or they need to be calculated with logic I need to run some code to figure them out in the Router, but this logic only requires the supergraph schema file and some environment variables and does not change after that
Describe the solution you'd like
supergraphReload()
so that I can change the subgraph info used when ever the Router starts or gets a new supergraph filehttps://users-subgraph.${K8_DOMAIN}.company.svc.local
and be populated by Router on supergraph reloadsDescribe alternatives you've considered Using coprocessor or Rhai scripts I can apply some logic on every single request to change the subgraph URL, but the logic I have does not change per-request. It is static and could be calculated once from the supergraph info and environment variables
Additional context Rover today does validate routing URLs so that logic might have to change: https://github.com/apollographql/rover/issues/1689