0

Debugging database queries in Django is commonly done with the Django Debug Toolbar or similar middlewares. However when using Graphene / GraphQL, these queries are not captured. Is there a method to view these queries apart from logging all queries? I am running an ASGI where the some code paths are logged (Django admin, user authentication) but not those from Graphene. Could this be related to https://github.com/jazzband/django-debug-toolbar/issues/1430 ?

For my use case in particular I want to analyze GraphQL queries. However for the following query these are the logged queries. The request returns a number of entries.

{
  allPeripheralComponents {
    edges {
      node {
        id
        siteEntity{
          name
        }
        peripheralType
        dataPointTypeSet{
          edges{
            node{
              id
              name
              unit
            }
          }
        }
      }
    }
  }
}

enter image description here

Moritz
  • 2,987
  • 3
  • 21
  • 34
  • 1
    See [the documentation](https://docs.graphene-python.org/projects/django/en/latest/debug/) for graphene-django. –  Feb 21 '21 at 15:40
  • That is very useful, but also as the documentation points out, does not integrate directly into DDT, but as the raw queries themselves. It does not list the query times, but is still quite useful to gauge how expensive a query is. – Moritz Feb 22 '21 at 10:06
  • Look at `graphene_django.debug.sql.types`. There's more you can query for, including duration and start/stop time. –  Feb 22 '21 at 23:13

0 Answers0