Skip to content

Commit

Permalink
feat(strawberry): Support Strawberry 0.239.2 (#3491)
Browse files Browse the repository at this point in the history
Update our Strawberry integration to support the latest versions of Strawberry, following upstream breaking changes which caused our tests to fail.

Closes #3490

Co-authored-by: Ivana Kellyer <[email protected]>
  • Loading branch information
szokeasaurusrex and sentrivana authored Sep 3, 2024
1 parent cd15bff commit 9df2b21
Showing 1 changed file with 5 additions and 5 deletions.
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

0 comments on commit 9df2b21

Please sign in to comment.