Skip to content

Commit a4adbc5

Browse files
committed
Document why GraphQL is used over REST in listBranches
Two REST limitations make GraphQL necessary: 1. REST branches endpoint has no search/filter param (query is GraphQL-only) 2. REST only supports integer page offsets (per-edge cursors are GraphQL-only)
1 parent ba15102 commit a4adbc5

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/VCS/Adapter/Git/GitHub.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,10 +783,15 @@ public function listBranches(string $owner, string $repositoryName, int $perPage
783783
}
784784
GRAPHQL;
785785

786-
// GitHub's GraphQL query param does substring matching, so we request edges
787-
// (which carry per-item cursors) and enforce prefix semantics client-side with
788-
// str_starts_with. We collect up to $perPage + 1 matching edges across as many
789-
// GitHub API pages as needed:
786+
// We use GraphQL instead of REST for two reasons that the REST API cannot satisfy:
787+
// 1. Server-side search narrowing: REST GET /repos/{owner}/{repo}/branches has no
788+
// search or filter parameter at all; GraphQL refs() accepts a `query` variable.
789+
// 2. Per-edge cursors: REST only supports integer ?page=N offsets; GraphQL edges
790+
// carry individual cursors so we can resume from an exact item across calls.
791+
//
792+
// GraphQL `query` does substring matching, so we additionally enforce prefix
793+
// semantics client-side with str_starts_with. We collect up to $perPage + 1
794+
// matching edges across as many GraphQL pages as needed:
790795
// - If we find the +1 probe item, hasNext=true and nextCursor points to the
791796
// cursor of the last returned item, so the next call resumes exactly where
792797
// we stopped.

0 commit comments

Comments
 (0)