Repository: strawberry-graphql/strawberry

Issue:
Subscription is not working with permission_classes
<!-- Provide a general summary of the bug in the title above. -->
Subscription is failing with error after upgrading to version 0.217.0 from 0.216.1. Bug seems to be in `permission_classes`, because if I'm trying to use subscription without permission_classes, it works without any problem.

<!--- This template is entirely optional and can be removed, but is here to help both you and us. -->
<!--- Anything on lines wrapped in comments like these will not show up in the final text. -->

## Describe the Bug
Error when subscription is used with `permission_classes`:
```
Traceback (most recent call last):
  File "/.../lib/python3.11/site-packages/graphql/execution/subscribe.py", line 206, in execute_subscription
    event_stream = await event_stream
                   ^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/strawberry/schema/schema_converter.py", line 675, in _async_resolver
    return await await_maybe(
           ^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/strawberry/utils/await_maybe.py", line 12, in await_maybe
    return await value
           ^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/strawberry/permission.py", line 172, in resolve_async
    return await next_(source, info, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object async_generator can't be used in 'await' expression
```

Here is sample code to reproduce the bug:
```
class IsAuthenticated(BasePermission):

    message = "Unauthorized"

    async def has_permission(self, source: Any, info: Info, **kwargs: Any) -> bool:
        return True


async def sample(info: Info) -> AsyncGenerator[int, None]:
    while True:
        yield 1


@strawberry.type
class Subscription:
    sample = strawberry.subscription(
        resolver=sample, permission_classes=[IsAuthenticated]
    )
```

<!-- A clear and concise description of what the bug is. -->

## System Information

 - Strawberry version (if applicable): 0.217.0

<!-- Add any other relevant information about the problem here. -->


<!-- POLAR PLEDGE BADGE START -->
## Upvote & Fund

- We're using [Polar.sh](https://polar.sh/strawberry-graphql) so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.

<a href="https://polar.sh/strawberry-graphql/strawberry/issues/3317">
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://polar.sh/api/github/strawberry-graphql/strawberry/issues/3317/pledge.svg?darkmode=1">
  <img alt="Fund with Polar" src="https://polar.sh/api/github/strawberry-graphql/strawberry/issues/3317/pledge.svg">
</picture>
</a>
<!-- POLAR PLEDGE BADGE END -->



Discussion:
Permissions are powered by `FieldExtensions`. These currently do not explicitly support subscriptions since we only expect `awaitables` or non-awaitable values, not for `AsyncGenerators`. However, since the new `stream` feature in GraphQL-core also allows to make _every_ resolver an `AsyncGenerator`, we need to add support for it as part of #2914. I'll create a separate issue to track this in a moment.

Resolving patch:
diff --git a/strawberry/permission.py b/strawberry/permission.py
--- a/strawberry/permission.py
+++ b/strawberry/permission.py
@@ -1,6 +1,7 @@
 from __future__ import annotations
 
 import abc
+import inspect
 from functools import cached_property
 from inspect import iscoroutinefunction
 from typing import (
@@ -169,7 +170,10 @@ async def resolve_async(
 
             if not has_permission:
                 return self._on_unauthorized(permission)
-        return await next_(source, info, **kwargs)
+        next = next_(source, info, **kwargs)
+        if inspect.isasyncgen(next):
+            return next
+        return await next
 
     @cached_property
     def supports_sync(self) -> bool:


Test patch:
diff --git a/tests/schema/test_subscription.py b/tests/schema/test_subscription.py
--- a/tests/schema/test_subscription.py
+++ b/tests/schema/test_subscription.py
@@ -3,12 +3,19 @@
 
 import sys
 from collections import abc  # noqa: F401
-from typing import AsyncGenerator, AsyncIterable, AsyncIterator, Union  # noqa: F401
+from typing import (  # noqa: F401
+    Any,
+    AsyncGenerator,
+    AsyncIterable,
+    AsyncIterator,
+    Union,
+)
 from typing_extensions import Annotated
 
 import pytest
 
 import strawberry
+from strawberry.types import Info
 
 
 @pytest.mark.asyncio
@@ -34,6 +41,37 @@ async def example(self) -> AsyncGenerator[str, None]:
     assert result.data["example"] == "Hi"
 
 
+@pytest.mark.asyncio
+async def test_subscription_with_permission():
+    from strawberry import BasePermission
+
+    class IsAuthenticated(BasePermission):
+        message = "Unauthorized"
+
+        async def has_permission(self, source: Any, info: Info, **kwargs: Any) -> bool:
+            return True
+
+    @strawberry.type
+    class Query:
+        x: str = "Hello"
+
+    @strawberry.type
+    class Subscription:
+        @strawberry.subscription(permission_classes=[IsAuthenticated])
+        async def example(self) -> AsyncGenerator[str, None]:
+            yield "Hi"
+
+    schema = strawberry.Schema(query=Query, subscription=Subscription)
+
+    query = "subscription { example }"
+
+    sub = await schema.subscribe(query)
+    result = await sub.__anext__()
+
+    assert not result.errors
+    assert result.data["example"] == "Hi"
+
+
 @pytest.mark.asyncio
 async def test_subscription_with_arguments():
     @strawberry.type