Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit cfc7f31

Browse files
fix: Fix query for is_first_pull_request (#1258)
1 parent ea5980f commit cfc7f31

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

graphql_api/types/repository/repository.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
from graphql_api.actions.commits import repo_commits
1616
from graphql_api.dataloader.commit import CommitLoader
1717
from graphql_api.dataloader.owner import OwnerLoader
18-
from graphql_api.helpers.connection import (
19-
queryset_to_connection,
20-
)
18+
from graphql_api.helpers.connection import queryset_to_connection
2119
from graphql_api.types.coverage_analytics.coverage_analytics import (
2220
CoverageAnalyticsProps,
2321
)
@@ -273,13 +271,12 @@ def resolve_repository_result_type(obj: Any, *_: Any) -> Optional[str]:
273271
def resolve_is_first_pull_request(
274272
repository: Repository, info: GraphQLResolveInfo
275273
) -> bool:
276-
has_one_pr = repository.pull_requests.count() == 1
277-
278-
if has_one_pr:
279-
first_pr = repository.pull_requests.first()
280-
return not first_pr.compared_to
281-
282-
return False
274+
# Get at most 2 PRs to determine if there's only one
275+
pull_requests = repository.pull_requests.values("id", "compared_to")[:2]
276+
if len(pull_requests) != 1:
277+
return False
278+
# For single PR, check if it's a valid first PR by verifying no compared_to
279+
return pull_requests[0]["compared_to"] is None
283280

284281

285282
@repository_bindable.field("isGithubRateLimited")

0 commit comments

Comments
 (0)