You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run Schemathesis via Docker against your GraphQL endpoint:
9
9
10
10
```bash
11
-
pip install schemathesis
11
+
docker run schemathesis/schemathesis \
12
+
run https://your.app.com/graphql
12
13
```
13
14
14
-
Then, create a file `test_api.py` with the content below and replace the `URL` value with your own GraphQL endpoint URL:
15
+
Schemathesis will generate queries matching your GraphQL schema and catch server crashes automatically.
16
+
Generated queries have arbitrary depth and may contain any subset of GraphQL types defined in the input schema.
17
+
They expose edge cases in your code that are unlikely to be found otherwise.
15
18
16
-
```python
17
-
from hypothesis import settings
18
-
import schemathesis
19
+
Note that you can write your app in any programming language; the tool will communicate with it over HTTP.
19
20
20
-
URL="https://your.app.com/graphql"
21
-
schema = schemathesis.graphql.from_url(URL)
21
+
For example, running the command above against `https://bahnql.herokuapp.com/graphql` uncovers that running the `{ search(searchTerm: "") { stations { name } } }` query leads to a server error:
22
22
23
-
@schema.parametrize()
24
-
@settings(deadline=None)
25
-
deftest_api(case):
26
-
response = case.call()
27
-
case.validate_response(response)
28
23
```
29
-
30
-
Then run `pytest test_api.py`. Note that you can write your app in any programming language; the tool will communicate with it over HTTP.
31
-
32
-
Schemathesis will generate valid queries automatically based on the schema and will minimize failing cases.
33
-
For example, running the code above against `https://bahnql.herokuapp.com/graphql` uncovers that running the `{ search(searchTerm: "") { stations { name } } }` query leads to a server error:
34
-
35
-
```
36
-
{"errors":[{"message":"Cannot read property \'city\' of undefined","locations":[{"line":1,"column":28}],"path":["search","stations"]}],"data":null}
24
+
{
25
+
"errors": [
26
+
{
27
+
"message": "Cannot read property 'city' of undefined",
0 commit comments