Label facets#461
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds label-based facets across multiple GraphQL connections (workloads + persistence resources) and refactors facet computation to be lazy and request-scoped, avoiding repeated filter work when multiple facet fields are requested in the same query.
Changes:
- Introduces a shared
LabelFacetItemGraphQL type and addslabelsfacet fields to multiple*FacetsGraphQL types. - Refactors facet implementations to methods on
*Facetsstructs withsync.Once-cached filtering, enabling safe concurrent field resolution. - Adds shared facet helpers in
internal/graph/modelfor environments and labels; updates resolvers and generated GraphQL code accordingly.
Reviewed changes
Copilot reviewed 47 out of 58 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/workload/secret/queries.go | Stops pre-filtering watcher results so facets can be computed over the full team scope. |
| internal/workload/secret/models.go | Refactors SecretFacets to hold request-scope data + cached filtered results. |
| internal/workload/secret/facets.go | Moves facet computation to methods; adds label facets for secrets. |
| internal/workload/job/models.go | Refactors JobFacets to request-scope fields + cached filtering. |
| internal/workload/job/facets.go | Moves facet computation to methods; adds label facets for jobs. |
| internal/workload/config/queries.go | Stops pre-filtering watcher results so facets can be computed over the full team scope. |
| internal/workload/config/models.go | Refactors ConfigFacets to request-scope fields + cached filtered results. |
| internal/workload/config/facets.go | Moves facet computation to methods; adds label facets for configs. |
| internal/workload/application/models.go | Refactors ApplicationFacets to request-scope fields + cached filtering. |
| internal/workload/application/facets.go | Moves facet computation to methods; adds label facets for applications. |
| internal/persistence/valkey/models.go | Refactors ValkeyFacets to request-scope fields + cached filtered results. |
| internal/persistence/valkey/facets.go | Moves facet computation to methods; adds label facets for Valkey. |
| internal/persistence/postgres/models.go | Refactors PostgresInstanceFacets to request-scope fields + cached filtered results. |
| internal/persistence/postgres/facets.go | Moves facet computation to methods; adds label facets for Postgres instances. |
| internal/persistence/postgres/facets_test.go | Updates tests to use new facets methods (but does not yet test label facets). |
| internal/persistence/opensearch/models.go | Refactors OpenSearchFacets to request-scope fields + cached filtered results. |
| internal/persistence/opensearch/facets.go | Moves facet computation to methods; adds label facets for OpenSearch. |
| internal/persistence/kafkatopic/models.go | Refactors KafkaTopicFacets to request-scope fields + cached filtered results. |
| internal/persistence/kafkatopic/facets.go | Moves facet computation to methods; adds label facets for Kafka topics. |
| internal/persistence/bucket/models.go | Refactors BucketFacets to request-scope fields + cached filtered results. |
| internal/persistence/bucket/facets.go | Moves facet computation to methods; adds label facets for buckets. |
| internal/persistence/bigquery/models.go | Refactors BigQueryDatasetFacets to request-scope fields + cached filtered results. |
| internal/persistence/bigquery/facets.go | Moves facet computation to methods; adds label facets for BigQuery datasets. |
| internal/graph/valkey.resolvers.go | Returns ValkeyFacets object instead of precomputed facets. |
| internal/graph/secret.resolvers.go | Returns SecretFacets object instead of precomputed facets. |
| internal/graph/postgres.resolvers.go | Returns PostgresInstanceFacets object instead of precomputed facets. |
| internal/graph/opensearch.resolvers.go | Returns OpenSearchFacets object instead of precomputed facets. |
| internal/graph/kafka.resolvers.go | Returns KafkaTopicFacets object instead of precomputed facets. |
| internal/graph/jobs.resolvers.go | Returns JobFacets object instead of precomputed facets. |
| internal/graph/config.resolvers.go | Returns ConfigFacets object instead of precomputed facets. |
| internal/graph/bucket.resolvers.go | Returns BucketFacets object instead of precomputed facets. |
| internal/graph/bigquery.resolvers.go | Returns BigQueryDatasetFacets object instead of precomputed facets. |
| internal/graph/applications.resolvers.go | Returns ApplicationFacets object instead of precomputed facets. |
| internal/graph/schema/valkey.graphqls | Adds labels to ValkeyFacets. |
| internal/graph/schema/secret.graphqls | Adds labels to SecretFacets. |
| internal/graph/schema/postgres.graphqls | Adds labels to PostgresInstanceFacets. |
| internal/graph/schema/opensearch.graphqls | Adds labels to OpenSearchFacets. |
| internal/graph/schema/kafka.graphqls | Adds labels to KafkaTopicFacets. |
| internal/graph/schema/jobs.graphqls | Adds labels to JobFacets. |
| internal/graph/schema/facets.graphqls | Adds shared LabelFacetItem type. |
| internal/graph/schema/config.graphqls | Adds labels to ConfigFacets. |
| internal/graph/schema/bucket.graphqls | Adds labels to BucketFacets. |
| internal/graph/schema/bigquery.graphqls | Adds labels to BigQueryDatasetFacets. |
| internal/graph/schema/applications.graphqls | Adds labels to ApplicationFacets. |
| internal/graph/model/facets.go | Adds LabelFacetItem, label sorting, and shared facet computation helpers. |
| internal/graph/gengql/valkey.generated.go | Regenerates GraphQL execution code for method-based facets + labels. |
| internal/graph/gengql/secret.generated.go | Regenerates GraphQL execution code for method-based facets + labels. |
| internal/graph/gengql/root_.generated.go | Regenerates schema/complexity plumbing for new fields/types. |
| internal/graph/gengql/postgres.generated.go | Regenerates GraphQL execution code for method-based facets + labels. |
| internal/graph/gengql/opensearch.generated.go | Regenerates GraphQL execution code for method-based facets + labels. |
| internal/graph/gengql/kafka.generated.go | Regenerates GraphQL execution code for method-based facets + labels. |
| internal/graph/gengql/jobs.generated.go | Regenerates GraphQL execution code for method-based facets + labels. |
| internal/graph/gengql/facets.generated.go | Regenerates GraphQL execution code for new LabelFacetItem type. |
| internal/graph/gengql/config.generated.go | Regenerates GraphQL execution code for method-based facets + labels. |
| internal/graph/gengql/bucket.generated.go | Regenerates GraphQL execution code for method-based facets + labels. |
| internal/graph/gengql/bigquery.generated.go | Regenerates GraphQL execution code for method-based facets + labels. |
| internal/graph/gengql/applications.generated.go | Regenerates GraphQL execution code for method-based facets + labels. |
| integration_tests/label_selectors.lua | Adds integration coverage for Valkey label facets. |
Files not reviewed (11)
- internal/graph/gengql/applications.generated.go: Language not supported
- internal/graph/gengql/bigquery.generated.go: Language not supported
- internal/graph/gengql/bucket.generated.go: Language not supported
- internal/graph/gengql/config.generated.go: Language not supported
- internal/graph/gengql/facets.generated.go: Language not supported
- internal/graph/gengql/jobs.generated.go: Language not supported
- internal/graph/gengql/kafka.generated.go: Language not supported
- internal/graph/gengql/opensearch.generated.go: Language not supported
- internal/graph/gengql/postgres.generated.go: Language not supported
- internal/graph/gengql/secret.generated.go: Language not supported
- internal/graph/gengql/valkey.generated.go: Language not supported
Comment on lines
+95
to
+102
| for _, item := range filtered { | ||
| for _, lbl := range getLabels(item) { | ||
| if lbl == nil { | ||
| continue | ||
| } | ||
| labelCounts[lbl.Key][lbl.Value]++ | ||
| } | ||
| } |
Comment on lines
+214
to
+217
| got := &PostgresInstanceFacets{ | ||
| AllInstances: tt.instances, | ||
| Filter: tt.filter, | ||
| } |
a9bd6ad to
ee29efe
Compare
Introduce `LabelFacetItem` in GraphQL and expose `labels` facets for all labelled resources. Change facet fields to be calculated using a resolver method to prevent excess calculations when not necessary.
christeredvartsen
approved these changes
Jun 9, 2026
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.
No description provided.