Batch deployment commit lookups in GraphQL
What does this MR do and why?
DeploymentType's commit field fell through to Deployment#commit, which is
@commit ||= project.commit(sha) — one Gitaly FindCommit round trip per
deployment. Querying commit on a list of deployments (for example, an
environment's deployments connection) produced an N+1: N deployments meant N
Gitaly calls.
This adds a thin GraphQL resolver that uses Commit.lazy, the existing
BatchLoader that groups commit lookups per repository and resolves them in a
single commits_by (ListCommitsByOid) request. The model's Deployment#commit
is intentionally left unchanged, since it is used synchronously elsewhere; only
the GraphQL resolution path is batched.
Before / after
For a deployments { nodes { commit { sha } } } query over N deployments:
| Gitaly calls for commits | |
|---|---|
| Before | N (one FindCommit per deployment) |
| After | 1 (one batched commits_by) |