mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 20:54:16 +03:00
Added Django Debug page
This commit is contained in:
parent
7b06e01cb3
commit
53b3133af5
|
@ -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]
|
||||
|
|
51
docs/pages/docs/django/debug.md
Normal file
51
docs/pages/docs/django/debug.md
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user