Skip to content

self.execution_context.result.extensions is not displayed in response #756

@team-jaitq

Description

@team-jaitq

Describe the Bug

When I implemented an extension and I setted a value to self.execution_context.result.extensions. This field is not shown in the response.
I've already debugged and the value is setted properly, but it's not shown in the response.

import strawberry
from models.product import Product

@strawberry.type
class ProductQuery:
    @strawberry.field
    @classmethod
    def product_by_slug(cls, slug: str) -> Product:
        return Product.objects.get(slug=slug)
from strawberry.extensions import SchemaExtension

class ResponseExtension(SchemaExtension):

    def on_request_end(self):
        result = self.execution_context.result
        if not result.extensions:
            result.extensions = {}
        result.extensions["field1"] = "value1"
        result.extensions["field2"] = "value2"
        print(self.execution_context.result.extensions)
@strawberry.type
class Query(
    ProductQuery
):
    pass

schema = strawberry.Schema(
    query=Query,
    extensions=[
        ResponseExtension
    ]
)

There is no extensions field in the response

{
  "data": {
    "productBySlug": {
      "name": "myname"
    }
  }
  # extensions: {} should be displayed on this level.
}

System Information

  • Operating system: Windows
  • Strawberry version: strawberry-graphql-django==0.60.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