From 9fb457f3b7df1de16d0cd7e0966dfc4b03eb2821 Mon Sep 17 00:00:00 2001 From: Nico Virkki Date: Tue, 4 Jun 2024 16:35:09 +0300 Subject: [PATCH] fix: dont check fields in middleware when missing service Don't try to check fields if service exists Refs HP-2319 --- open_city_profile/graphene.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/open_city_profile/graphene.py b/open_city_profile/graphene.py index 05dd65f8..e4bef01c 100644 --- a/open_city_profile/graphene.py +++ b/open_city_profile/graphene.py @@ -189,7 +189,8 @@ def resolve(self, next, root, info, **kwargs): if getattr(root, "check_allowed_data_fields", False): field_name = to_snake_case(getattr(info, "field_name", "")) - if not getattr(info.context, "service", False): + service = getattr(info.context, "service", None) + if not service: if settings.ENABLE_ALLOWED_DATA_FIELDS_RESTRICTION: raise ServiceNotIdentifiedError("Service not identified") @@ -198,7 +199,9 @@ def resolve(self, next, root, info, **kwargs): field_name, ) - if not root.is_field_allowed_for_service(field_name, info.context.service): + return next(root, info, **kwargs) + + if not root.is_field_allowed_for_service(field_name, service): if settings.ENABLE_ALLOWED_DATA_FIELDS_RESTRICTION: raise FieldNotAllowedError( "Field is not allowed for service.", field_name=field_name