You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.5 KiB

Django Debug Middleware

You can debug your GraphQL queries in a similar way to django-debug-toolbar, 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.


For use the Django Debug plugin in Graphene:

  • Add graphene_django.debug.DjangoDebugMiddleware into MIDDLEWARE in the GRAPHENE settings.
  • Add the debug field into the schema root Query with the value graphene.Field(DjangoDebug, name='_debug').
from graphene_django.debug import DjangoDebug

class Query(graphene.ObjectType):
    # ...
    debug = graphene.Field(DjangoDebug, name='_debug')

schema = graphene.Schema(query=Query)

And in your



You can query it for outputing all the sql transactions that happened in the GraphQL request, like:

  # A example that will use the ORM for interact with the DB
  allIngredients {
    edges {
      node {
  # Here is the debug field that will output the SQL queries
  _debug {
    sql {

Note that the _debug field must be the last field in your query.