Skip to content

Commit

Permalink
test(integrations): Add test for setting transaction name of graphene…
Browse files Browse the repository at this point in the history
… query getsentry#2704

This commit adds a missing test for the graphene integration, so that we can be sure that a transaction with the corresponding query name is captured.
  • Loading branch information
czyber committed Feb 24, 2024
1 parent f4cad58 commit b6edb54
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/integrations/graphene/test_graphene_py3.py
Expand Up @@ -201,3 +201,32 @@ def graphql_server_sync():
client.post("/graphql", json=query)

assert len(events) == 0


def test_transaction_name_sync(sentry_init, capture_events):
sentry_init(
integrations=[GrapheneIntegration()],
enable_tracing=True,
auto_enabling_integrations=False,
)
events = capture_events()

schema = Schema(query=Query)

sync_app = Flask(__name__)

@sync_app.post("/graphql")
def graphql_server_sync():
data = request.get_json()
result = schema.execute(data["query"], operation_name=data.get("operationName"))
return result.data

query = {"query": "query GreetingQuery { hello }", "operationName": "GreetingQuery"}
client = sync_app.test_client()
client.post("/graphql", json=query)

assert len(events) == 1

(transaction_event,) = events
assert transaction_event["transaction"] == "GreetingQuery"
assert transaction_event["type"] == "transaction"

0 comments on commit b6edb54

Please sign in to comment.