Skip to content

Conversation

@thokra-nav
Copy link
Contributor

requests to fetch all workloads.

This optimizes the response in the case of asking only for the count instead of fields for workloads related to CVEs

requests to fetch all workloads.

This optimizes the response in the case of asking only for the count
instead of fields for workloads related to CVEs
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes GraphQL query performance by short-circuiting workload fetching when clients only request the total count of affected workloads for CVEs. Instead of fetching all workload data, the API now returns just the count if that's all that's requested.

Changes:

  • Added AffectedWorkloads field to the CVE struct to cache the count from API responses
  • Created onlyAsksForPageInfoTotalCount helper to detect when only count is requested via GraphQL field introspection
  • Added NewTotalCountOnlyConnection utility to create paginated connections with only a total count

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/vulnerability/models.go Added AffectedWorkloads field to cache workload count
internal/vulnerability/queries.go Populates AffectedWorkloads when listing CVEs
internal/graph/pagination/models.go Added utility function for total-count-only connections
internal/graph/helpers.go Added GraphQL field introspection helpers to detect count-only queries
internal/graph/vulnerability.resolvers.go Implements short-circuit optimization in Workloads resolver

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rbjornstad rbjornstad marked this pull request as ready for review January 22, 2026 08:53
@rbjornstad rbjornstad requested a review from a team as a code owner January 22, 2026 08:53
@rbjornstad rbjornstad merged commit 65707c8 into main Jan 22, 2026
10 checks passed
@rbjornstad rbjornstad deleted the optimize_cve_workloads branch January 22, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants