From 80df22ebb30eb621bc37135bbf9b38feefc085e2 Mon Sep 17 00:00:00 2001 From: Arthur Bayr Date: Thu, 17 Oct 2024 16:44:26 +0200 Subject: [PATCH] https://github.com/strawberry-graphql/strawberry/issues/3596 --- strawberry/permission.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/strawberry/permission.py b/strawberry/permission.py index b52fdce102..47a4c0a94f 100644 --- a/strawberry/permission.py +++ b/strawberry/permission.py @@ -158,9 +158,12 @@ def __init__( def apply(self, field: StrawberryField) -> None: """Applies all of the permission directives to the schema and sets up silent permissions.""" if self.use_directives: - field.directives.extend( - p.schema_directive for p in self.permissions if p.schema_directive - ) + # Dedupe multiple directives + # https://github.com/strawberry-graphql/strawberry/issues/3596 + permission_directives = {p.schema_directive for p in self.permissions if p.schema_directive} + existing_field_directives = set(field.directives) + extend_directives = permission_directives - existing_field_directives + field.directives.extend(extend_directives) # We can only fail silently if the field is optional or a list if self.fail_silently: if isinstance(field.type, StrawberryOptional):