Skip to content

feat(strawberry): Support Strawberry 0.239.2 #3491

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

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions sentry_sdk/integrations/strawberry.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Any, Callable, Generator, List, Optional
from typing import Any, Callable, Generator, List, Optional, Union
from graphql import GraphQLError, GraphQLResolveInfo # type: ignore
from strawberry.http import GraphQLHTTPResponse
from strawberry.types import ExecutionContext, ExecutionResult # type: ignore
from strawberry.types import ExecutionContext, ExecutionResult, SubscriptionExecutionResult # type: ignore
from sentry_sdk._types import Event, EventProcessor


Expand Down Expand Up @@ -291,13 +291,13 @@ def _patch_execute():
old_execute_sync = strawberry_schema.execute_sync

async def _sentry_patched_execute_async(*args, **kwargs):
# type: (Any, Any) -> ExecutionResult
# type: (Any, Any) -> Union[ExecutionResult, SubscriptionExecutionResult]
result = await old_execute_async(*args, **kwargs)

if sentry_sdk.get_client().get_integration(StrawberryIntegration) is None:
return result

if "execution_context" in kwargs and result.errors:
if "execution_context" in kwargs:
scope = sentry_sdk.get_isolation_scope()
event_processor = _make_request_event_processor(kwargs["execution_context"])
scope.add_event_processor(event_processor)
Expand All @@ -309,7 +309,7 @@ def _sentry_patched_execute_sync(*args, **kwargs):
# type: (Any, Any) -> ExecutionResult
result = old_execute_sync(*args, **kwargs)

if "execution_context" in kwargs and result.errors:
if "execution_context" in kwargs:
scope = sentry_sdk.get_isolation_scope()
event_processor = _make_request_event_processor(kwargs["execution_context"])
scope.add_event_processor(event_processor)
Expand Down
Loading