diff --git a/graphql_api/tests/test_owner.py b/graphql_api/tests/test_owner.py index e6955a94db..09b9510dd9 100644 --- a/graphql_api/tests/test_owner.py +++ b/graphql_api/tests/test_owner.py @@ -25,7 +25,6 @@ from billing.helpers import mock_all_plans_and_tiers from codecov.commands.exceptions import ( - MissingService, UnauthorizedGuestAccess, ) from codecov_auth.models import GithubAppInstallation, OwnerProfile @@ -708,7 +707,6 @@ def test_owner_query_with_no_service(self): res = self.gql_request(query, provider="", with_errors=True) - assert res["errors"][0]["message"] == MissingService.message assert res["data"]["owner"] is None def test_owner_query_with_private_repos(self): @@ -1195,3 +1193,19 @@ def test_fetch_available_plans_is_enterprise_plan(self): ] } } + + def test_fetch_owner_with_no_service(self): + current_org = OwnerFactory( + username="random-plan-user", + service="github", + plan=PlanName.BASIC_PLAN_NAME.value, + ) + + query = """{ + owner(username: "%s") { + username + } + } + """ % (current_org.username) + data = self.gql_request(query, owner=current_org, provider="", with_errors=True) + assert data == {"data": {"owner": None}} diff --git a/graphql_api/types/errors/errors.graphql b/graphql_api/types/errors/errors.graphql index 0b92a052f4..68b1d84971 100644 --- a/graphql_api/types/errors/errors.graphql +++ b/graphql_api/types/errors/errors.graphql @@ -37,3 +37,7 @@ type ProviderError implements ResolverError { type OwnerNotActivatedError implements ResolverError { message: String! } + +type MissingService implements ResolverError { + message: String! +} diff --git a/graphql_api/types/mutation/update_default_organization/update_default_organization.graphql b/graphql_api/types/mutation/update_default_organization/update_default_organization.graphql index eb2624fe36..2dbe5cf426 100644 --- a/graphql_api/types/mutation/update_default_organization/update_default_organization.graphql +++ b/graphql_api/types/mutation/update_default_organization/update_default_organization.graphql @@ -1,4 +1,4 @@ -union UpdateDefaultOrganizationError = UnauthenticatedError | ValidationError +union UpdateDefaultOrganizationError = UnauthenticatedError | ValidationError | MissingService type UpdateDefaultOrganizationPayload { error: UpdateDefaultOrganizationError diff --git a/graphql_api/types/query/query.py b/graphql_api/types/query/query.py index ab4064130d..30bde8a686 100644 --- a/graphql_api/types/query/query.py +++ b/graphql_api/types/query/query.py @@ -46,6 +46,9 @@ async def resolve_owner( configure_sentry_scope(query_name(info)) service = info.context["service"] + if not service: + return None + user = info.context["request"].current_owner or info.context["request"].user if settings.IS_ENTERPRISE and settings.GUEST_ACCESS is False: