Skip to content
Open
Show file tree
Hide file tree
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
59 changes: 19 additions & 40 deletions sentry_sdk/integrations/strawberry.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,50 +366,29 @@ def _make_request_event_processor(
def inner(event: "Event", hint: "dict[str, Any]") -> "Event":
client_options = sentry_sdk.get_client().options
with capture_internal_exceptions():
if has_data_collection_enabled(client_options):
request_data = event.setdefault("request", {})
if client_options["data_collection"]["graphql"]["document"]:
request_data["api_target"] = "graphql"

if not request_data.get("data"):
execution_context_data: "dict[str, Any]" = (
{"query": execution_context.query}
if client_options["data_collection"]["graphql"]["document"]
else {}
)

if (
client_options["data_collection"]["graphql"]["variables"]
and execution_context.variables
):
execution_context_data["variables"] = (
execution_context.variables
)

if execution_context.operation_name:
execution_context_data["operationName"] = (
execution_context.operation_name
)

request_data["data"] = execution_context_data
elif should_send_default_pii():
request_data = event.setdefault("request", {})
request_data = event.setdefault("request", {})
if client_options["data_collection"]["graphql"]["document"]:
request_data["api_target"] = "graphql"

if not request_data.get("data"):
data: "dict[str, Any]" = {"query": execution_context.query}
if execution_context.variables:
data["variables"] = execution_context.variables
if execution_context.operation_name:
data["operationName"] = execution_context.operation_name
if not request_data.get("data"):
execution_context_data: "dict[str, Any]" = (
{"query": execution_context.query}
if client_options["data_collection"]["graphql"]["document"]
else {}
)

request_data["data"] = data
if (
client_options["data_collection"]["graphql"]["variables"]
and execution_context.variables
):
execution_context_data["variables"] = execution_context.variables

else:
try:
del event["request"]["data"]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whether this is added or not is now controlled by the data_collection.http_bodies flag within _wsgi_common, so this doesn't need to be here anymore.

except (KeyError, TypeError):
pass
if execution_context.operation_name:
execution_context_data["operationName"] = (
execution_context.operation_name
)

request_data["data"] = execution_context_data

return event

Expand Down
Loading
Loading