Skip to content

Commit

Permalink
fix: dont check fields in middleware when missing service
Browse files Browse the repository at this point in the history
Don't try to check fields if service does not exists

Refs HP-2319
  • Loading branch information
nicobav committed Jun 4, 2024
1 parent 3b18fbc commit ba414e4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions open_city_profile/graphene.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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
Expand Down

0 comments on commit ba414e4

Please sign in to comment.