Add effectiveAlertConfig GraphQL query#3227
Open
GregorShear wants to merge 2 commits into
Open
Conversation
Add a top-level `effectiveAlertConfig(catalogPrefixOrName)` query that resolves the effective alert config for a single prefix or catalog name, merging all ancestor prefix layers over controller defaults. Unlike `alertConfigs`, this does not require an `alert_configs` row to exist at the scope, so it works for prefixes and names that carry no explicit config and are therefore absent from the `alertConfigs` listing — a convenience for looking up the resolved config at an arbitrary scope. The resolver reuses the existing `resolve_effective_alert_config` helper (the same code path behind the `effective` field on AlertConfigEntry and `effectiveAlertConfig` on liveSpec) and authorizes `Read` on the requested scope.
Add an `is` field to the shared `PrefixFilter` input alongside `starts_with`, letting clients request a single row by its exact `catalog_prefix_or_name` rather than a prefix match. This is convenient for looking up the config at one specific prefix without also pulling in its descendants. Wire it into both consumers of `PrefixFilter` — the `alertConfigs` and `inviteLinks` list queries — so the new field is never a silent no-op: each adds an exact-equality WHERE condition and uses the exact value (when present) as the authorized-prefix narrowing hint, exactly as `starts_with` already does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two related additions to alert-config querying in the control-plane GraphQL API:
effectiveAlertConfig(catalogPrefixOrName: String!): EffectiveAlertConfig!that resolves the effective alert config for a single prefix or catalog name — merging all ancestor prefix layers over controller defaults.isexact-match field on the sharedPrefixFilterinput, alongside the existingstarts_with.Why
The existing
alertConfigsquery only lists prefixes/names that have an explicit row inalert_configs, each exposing aneffectivefield. There was no way to ask "what is the resolved effective config at scope X?" for a scope that carries no explicit config and is therefore absent from the listing.effectiveAlertConfigis that convenience.Separately,
alertConfigscould only filter by prefix match (startsWith), so requesting one specific prefix also pulled in all of its descendants.islets a client request a single row by exactcatalog_prefix_or_name.isvseffectiveAlertConfig— which to useThese answer different questions, and both are now available:
alertConfigs(filter: { catalogPrefixOrName: { is: \"acmeCo/prod/\" } })returns the stored row at exactly that scope, if one exists — and an empty list if there is no explicit config there. It never resolves inheritance.effectiveAlertConfig(catalogPrefixOrName: \"acmeCo/prod/\")returns the resolved config at that scope, merging ancestor layers and controller defaults, whether or not a row exists there.So
isis "show me the raw override stored here";effectiveAlertConfigis "show me what actually applies here."How
effectiveAlertConfigqueryresolve_effective_alert_confighelper — the same code path behind theeffectivefield onAlertConfigEntryandeffectiveAlertConfigonliveSpec— so resolution/merge/provenance behavior is identical./) or an exact catalog name, validated via the sharedvalidate_prefix_or_namehelper. This mirrors theupdateAlertConfigmutation's input, giving read/write symmetry at a scope.Readon the requested scope (satisfiable byReadon any ancestor prefix); ancestor layers merged into the result are visible to anyone who can read the scope, matching the existingeffective/effectiveAlertConfigfields.isfilterPrefixFilteris shared by thealertConfigsandinviteLinkslist queries, soisis wired into both — each adds an exact-equalityWHEREcondition and uses the exact value (when present) as the authorized-prefix narrowing hint, exactly asstartsWithalready does. Wiring both avoids exposing an input that silently does nothing.Regenerates the checked-in
control-plane-api.graphqlSDL and the sqlx offline query cache.Testing
test_effective_alert_config_query: a prefix with no explicit row resolves entirely from defaults (source: nullprovenance); a deeply-nested prefix with no row of its own inherits an ancestor override, with provenance attributing the overridden field to the ancestor; read on an unauthorized prefix is denied.test_alert_configs_filter_is:is: \"aliceCo/\"returns onlyaliceCo/, whilestartsWith: \"aliceCo/\"returnsaliceCo/and its descendant.