Skip to content

Commit 53b3133

Browse files
committed
Added Django Debug page
1 parent 7b06e01 commit 53b3133

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

docs/config.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ ga = "UA-12613282-7"
2222
name = "Django"
2323
pages = [
2424
"/docs/django/tutorial/",
25-
"/docs/django/authorization/",
2625
"/docs/django/filtering/",
26+
"/docs/django/authorization/",
27+
"/docs/django/debug/",
2728
]
2829

2930
[docs.sqlalchemy]

docs/pages/docs/django/debug.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Django Debug Plugin
3+
description: How to debug Django queries and requests using Graphene
4+
---
5+
6+
# Django Debug Plugin
7+
8+
You can debug your GraphQL queries in a similar way to [django-debug-toolbar](https://django-debug-toolbar.readthedocs.org/),
9+
but outputing in the results in GraphQL response as fields, instead of the graphical HTML interface.
10+
11+
12+
For that, you will need to add the plugin in your graphene schema.
13+
14+
## Installation
15+
16+
For use the Django Debug plugin in Graphene, just import `DjangoDebugPlugin` and add it to the `plugins` argument when you initiate the `Schema`.
17+
18+
19+
```python
20+
from graphene.contrib.django.debug import DjangoDebugPlugin
21+
22+
# ...
23+
schema = graphene.Schema(query=Query, plugins=[DjangoDebugPlugin()])
24+
```
25+
26+
This plugin, will add another field in the `Query` named `__debug`.
27+
28+
29+
## Querying
30+
31+
You can query it for outputing all the sql transactions that happened in the GraphQL request, like:
32+
33+
```graphql
34+
{
35+
# A example that will use the ORM for interact with the DB
36+
allIngredients {
37+
edges {
38+
node {
39+
id,
40+
name
41+
}
42+
}
43+
}
44+
# Here is the debug field that will output the SQL queries
45+
__debug {
46+
sql {
47+
rawSql
48+
}
49+
}
50+
}
51+
```

0 commit comments

Comments
 (0)