Skip to content

Commit

Permalink
feat: Add repoid to repository graphql schema (#1095)
Browse files Browse the repository at this point in the history
  • Loading branch information
spalmurray-codecov authored Jan 17, 2025
1 parent ab5c1ff commit 9f89174
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions graphql_api/tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"""

default_fields = """
repoid
name
active
private
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions graphql_api/types/repository/repository.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Repository is a named collection of files uploaded
"""
type Repository {
isFirstPullRequest: Boolean!
repoid: Int!
name: String!
active: Boolean!
activated: Boolean!
Expand Down
10 changes: 10 additions & 0 deletions graphql_api/types/repository/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9f89174

Please sign in to comment.