Skip to content

0.331.4

Choose a tag to compare

@botberry botberry released this 05 Oct 18:21
· 124 commits to main since this release

This release fixes how federation schemas add the _service and _entities
fields to the Query type.

Fields of the Query type were matched with these fields by their Python name
instead of their GraphQL name. A Query field named service was removed from
the schema, with only a "Query has overridden fields: service" warning:

@strawberry.type
class Query:
    @strawberry.field
    def service(self) -> str:  # was missing from the schema
        return "service"


schema = strawberry.federation.Schema(query=Query)

Fields like this are now kept. A Query that defines its own _service or
_entities field now uses it instead of the one Strawberry adds. Before, doing
this with your own _Service type failed with a DuplicatedTypeName error:

@strawberry.type(name="_Service")
class CustomService:
    sdl: str


@strawberry.type
class Query:
    @strawberry.field(name="_service")
    def custom_service(self) -> CustomService:
        return CustomService(sdl=load_sdl())

This release was contributed by @patrick91 in #4671