From 9f89174ddb69700df7efdadde947d5fcfe2e7144 Mon Sep 17 00:00:00 2001 From: Spencer Murray <159931558+spalmurray-codecov@users.noreply.github.com> Date: Fri, 17 Jan 2025 10:37:28 -0500 Subject: [PATCH] feat: Add repoid to repository graphql schema (#1095) --- graphql_api/tests/test_repository.py | 5 +++++ graphql_api/types/repository/repository.graphql | 1 + graphql_api/types/repository/repository.py | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/graphql_api/tests/test_repository.py b/graphql_api/tests/test_repository.py index c3cbbed093..259d9952e5 100644 --- a/graphql_api/tests/test_repository.py +++ b/graphql_api/tests/test_repository.py @@ -51,6 +51,7 @@ """ default_fields = """ + repoid name active private @@ -103,6 +104,7 @@ def setUp(self): @freeze_time("2021-01-01") def test_when_repository_has_no_coverage(self): repo = RepositoryFactory( + repoid=1, author=self.owner, active=True, private=True, @@ -122,6 +124,7 @@ def test_when_repository_has_no_coverage(self): + "coverageAnalytics { percentCovered commitSha hits misses lines },", ) == { "__typename": "Repository", + "repoid": 1, "name": "a", "active": True, "private": True, @@ -154,6 +157,7 @@ def test_when_repository_has_no_coverage(self): @freeze_time("2021-01-01") def test_when_repository_has_coverage(self): repo = RepositoryFactory( + repoid=1, author=self.owner, active=True, private=True, @@ -186,6 +190,7 @@ def test_when_repository_has_coverage(self): + "coverageAnalytics { percentCovered commitSha hits misses lines },", ) == { "__typename": "Repository", + "repoid": 1, "name": "b", "active": True, "latestCommitAt": None, diff --git a/graphql_api/types/repository/repository.graphql b/graphql_api/types/repository/repository.graphql index 22b45bce47..e2dd2d40f6 100644 --- a/graphql_api/types/repository/repository.graphql +++ b/graphql_api/types/repository/repository.graphql @@ -3,6 +3,7 @@ Repository is a named collection of files uploaded """ type Repository { isFirstPullRequest: Boolean! + repoid: Int! name: String! active: Boolean! activated: Boolean! diff --git a/graphql_api/types/repository/repository.py b/graphql_api/types/repository/repository.py index 1dfa95b6a3..65174e8137 100644 --- a/graphql_api/types/repository/repository.py +++ b/graphql_api/types/repository/repository.py @@ -41,6 +41,16 @@ repository_bindable.set_alias("latestCommitAt", "true_latest_commit_at") +@repository_bindable.field("repoid") +def resolve_repoid(repository: Repository, info: GraphQLResolveInfo) -> int: + return repository.repoid + + +@repository_bindable.field("name") +def resolve_name(repository: Repository, info: GraphQLResolveInfo) -> str: + return repository.name + + @repository_bindable.field("oldestCommitAt") def resolve_oldest_commit_at( repository: Repository, info: GraphQLResolveInfo