Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix interfaces with duplicate directives #3674

Merged
merged 12 commits into from
Oct 21, 2024
9 changes: 6 additions & 3 deletions strawberry/permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
bellini666 marked this conversation as resolved.
Show resolved Hide resolved
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):
Expand Down
Loading