strawberry-django-plus icon indicating copy to clipboard operation
strawberry-django-plus copied to clipboard

Permissions: applying IsAuthenticated directive to entire schema

Open gghdev opened this issue 1 year ago • 3 comments

Hi there,

Instead of applying the IsAuthenticated() directive to individual fields, I'm looking to apply this to an entire schema.

I'd wondered if this might work, but it doesn't:

authenticated_schema = gql.Schema(
    query=AuthenticatedQueries,
    mutation=AuthenticatedMutations,
    extensions=[SchemaDirectiveExtension],
    directives=[IsAuthenticated()]
)

I get a type error: Expected type 'Iterable[StrawberryDirective]', got 'list[IsAuthenticated]' instead And an actual error: AttributeError: 'IsAuthenticated' object has no attribute 'arguments'.

Any thoughts?

gghdev avatar Mar 14 '23 13:03 gghdev