Skip to content

Commit b873a31

Browse files
Add Strawberry GraphQL integration (#2393)
Capture GraphQL errors and spans when using Strawberry server side. The integration has an option called async_execution which controls whether to hook into Strawberry sync or async. If not provided, we try to guess based on whether an async web framework is installed. --------- Co-authored-by: Daniel Szoke <[email protected]>
1 parent 1b445c6 commit b873a31

File tree

6 files changed

+1097
-0
lines changed

6 files changed

+1097
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Test strawberry
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- release/**
8+
9+
pull_request:
10+
11+
# Cancel in progress workflows on pull_requests.
12+
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
17+
permissions:
18+
contents: read
19+
20+
env:
21+
BUILD_CACHE_KEY: ${{ github.sha }}
22+
CACHED_BUILD_PATHS: |
23+
${{ github.workspace }}/dist-serverless
24+
25+
jobs:
26+
test:
27+
name: strawberry, python ${{ matrix.python-version }}, ${{ matrix.os }}
28+
runs-on: ${{ matrix.os }}
29+
timeout-minutes: 30
30+
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
python-version: ["3.8","3.9","3.10","3.11"]
35+
# python3.6 reached EOL and is no longer being supported on
36+
# new versions of hosted runners on Github Actions
37+
# ubuntu-20.04 is the last version that supported python3.6
38+
# see https://github.com/actions/setup-python/issues/544#issuecomment-1332535877
39+
os: [ubuntu-20.04]
40+
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: actions/setup-python@v4
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
47+
- name: Setup Test Env
48+
run: |
49+
pip install coverage "tox>=3,<4"
50+
51+
- name: Test strawberry
52+
uses: nick-fields/retry@v2
53+
with:
54+
timeout_minutes: 15
55+
max_attempts: 2
56+
retry_wait_seconds: 5
57+
shell: bash
58+
command: |
59+
set -x # print commands that are executed
60+
coverage erase
61+
62+
# Run tests
63+
./scripts/runtox.sh "py${{ matrix.python-version }}-strawberry" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch &&
64+
coverage combine .coverage* &&
65+
coverage xml -i
66+
67+
- uses: codecov/codecov-action@v3
68+
with:
69+
token: ${{ secrets.CODECOV_TOKEN }}
70+
files: coverage.xml
71+
72+
73+
check_required_tests:
74+
name: All strawberry tests passed or skipped
75+
needs: test
76+
# Always run this, even if a dependent job failed
77+
if: always()
78+
runs-on: ubuntu-20.04
79+
steps:
80+
- name: Check for failures
81+
if: contains(needs.test.result, 'failure')
82+
run: |
83+
echo "One of the dependent jobs has failed. You may need to re-run it." && exit 1

sentry_sdk/consts.py

+7
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ class OP:
170170
FUNCTION = "function"
171171
FUNCTION_AWS = "function.aws"
172172
FUNCTION_GCP = "function.gcp"
173+
GRAPHQL_EXECUTE = "graphql.execute"
174+
GRAPHQL_MUTATION = "graphql.mutation"
175+
GRAPHQL_PARSE = "graphql.parse"
176+
GRAPHQL_RESOLVE = "graphql.resolve"
177+
GRAPHQL_SUBSCRIPTION = "graphql.subscription"
178+
GRAPHQL_QUERY = "graphql.query"
179+
GRAPHQL_VALIDATE = "graphql.validate"
173180
GRPC_CLIENT = "grpc.client"
174181
GRPC_SERVER = "grpc.server"
175182
HTTP_CLIENT = "http.client"

0 commit comments

Comments
 (0)