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

Commit 223cdff

Browse files
committed
return null for owner if no service is provided
1 parent 74e4159 commit 223cdff

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

graphql_api/tests/test_owner.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,3 +1195,19 @@ def test_fetch_available_plans_is_enterprise_plan(self):
11951195
]
11961196
}
11971197
}
1198+
1199+
def test_fetch_owner_with_no_service(self):
1200+
current_org = OwnerFactory(
1201+
username="random-plan-user",
1202+
service="github",
1203+
plan=PlanName.BASIC_PLAN_NAME.value,
1204+
)
1205+
1206+
query = """{
1207+
owner(username: "%s") {
1208+
username
1209+
}
1210+
}
1211+
""" % (current_org.username)
1212+
data = self.gql_request(query, owner=current_org, provider="", with_errors=True)
1213+
assert data == {"data": {"owner": None}}

graphql_api/types/query/query.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ async def resolve_owner(
4646
configure_sentry_scope(query_name(info))
4747

4848
service = info.context["service"]
49+
if not service:
50+
return None
51+
4952
user = info.context["request"].current_owner or info.context["request"].user
5053

5154
if settings.IS_ENTERPRISE and settings.GUEST_ACCESS is False:

0 commit comments

Comments
 (0)