Skip to content

Debug toolbar with batching #786

@Eraldo

Description

@Eraldo

Describe the Bug

I setup the debug toolbar as of: https://strawberry.rocks/docs/django/integrations/debug-toolbar
It works... until I enable batching.
It seems like batching breaks the debug toolbar.

You’ve hit a Strawberry-Django Debug Toolbar middleware bug/limitation: batched GraphQL responses are a JSON array, but the middleware assumes a single JSON object and then tries payload["debugToolbar"] → TypeError: list indices must be integers….

trace

django  | ERROR 2025-09-26 00:18:21,521 log 168 281473286467968 Internal Server Error: /api/graphql
django  | Traceback (most recent call last):
django  |   File "/usr/local/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
django  |     response = get_response(request)
django  |                ^^^^^^^^^^^^^^^^^^^^^
django  |   File "/usr/local/lib/python3.12/site-packages/strawberry_django/middlewares/debug_toolbar.py", line 148, in __call__
django  |     return self.process_request(request)
django  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django  |   File "/usr/local/lib/python3.12/site-packages/strawberry_django/middlewares/debug_toolbar.py", line 193, in process_request
django  |     _get_payload(request, response)
django  |   File "/usr/local/lib/python3.12/site-packages/strawberry_django/middlewares/debug_toolbar.py", line 82, in _get_payload
django  |     payload["debugToolbar"] = collections.OrderedDict(
django  |     ~~~~~~~^^^^^^^^^^^^^^^^
django  | TypeError: list indices must be integers or slices, not str
django  | [26/Sep/2025 00:18:21] "POST /api/graphql HTTP/1.1" 500 103962

System Information

  • Python version: 3.12
  • Strawberry version (if applicable):
    strawberry-graphql-django = "^0.65.1"
    strawberry-graphql = "^0.281.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions