File tree Expand file tree Collapse file tree 2 files changed +53
-1
lines changed Expand file tree Collapse file tree 2 files changed +53
-1
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,9 @@ ga = "UA-12613282-7"
22
22
name = " Django"
23
23
pages = [
24
24
" /docs/django/tutorial/" ,
25
- " /docs/django/authorization/" ,
26
25
" /docs/django/filtering/" ,
26
+ " /docs/django/authorization/" ,
27
+ " /docs/django/debug/" ,
27
28
]
28
29
29
30
[docs .sqlalchemy ]
Original file line number Diff line number Diff line change
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
+ ```
You can’t perform that action at this time.
0 commit comments