Added Django Debug page

This commit is contained in:
Syrus Akbary 2016-02-04 14:13:24 -08:00
parent 7b06e01cb3
commit 53b3133af5
2 changed files with 53 additions and 1 deletions

View File

@ -22,8 +22,9 @@ ga = "UA-12613282-7"
name = "Django"
pages = [
"/docs/django/tutorial/",
"/docs/django/authorization/",
"/docs/django/filtering/",
"/docs/django/authorization/",
"/docs/django/debug/",
]
[docs.sqlalchemy]

View File

@ -0,0 +1,51 @@
---
title: Django Debug Plugin
description: How to debug Django queries and requests using Graphene
---
# Django Debug Plugin
You can debug your GraphQL queries in a similar way to [django-debug-toolbar](https://django-debug-toolbar.readthedocs.org/),
but outputing in the results in GraphQL response as fields, instead of the graphical HTML interface.
For that, you will need to add the plugin in your graphene schema.
## Installation
For use the Django Debug plugin in Graphene, just import `DjangoDebugPlugin` and add it to the `plugins` argument when you initiate the `Schema`.
```python
from graphene.contrib.django.debug import DjangoDebugPlugin
# ...
schema = graphene.Schema(query=Query, plugins=[DjangoDebugPlugin()])
```
This plugin, will add another field in the `Query` named `__debug`.
## Querying
You can query it for outputing all the sql transactions that happened in the GraphQL request, like:
```graphql
{
# A example that will use the ORM for interact with the DB
allIngredients {
edges {
node {
id,
name
}
}
}
# Here is the debug field that will output the SQL queries
__debug {
sql {
rawSql
}
}
}
```