Skip to content

0.331.2

Choose a tag to compare

@botberry botberry released this 05 Oct 14:43
· 6 commits to main since this release

This release fixes a bug with nullable input fields.

Given the following Strawberry schema:

@strawberry.input
class RunInput:
    required: int
    optional: str | None


@strawberry.type
class Mutation:
    @strawberry.mutation
    def run(self, input: RunInput) -> int: ...

and the following GraphQL query:

mutation {
    run(input: {required: 42})
}

Previous versions of Strawberry raised a TypeError: RunInput.__init__() missing 1 required keyword-only argument: 'optional'.
This meant that clients had to explicitly specify nullable fields as null:

mutation {
    run(input: {required: 42, optional: null})
}

However, according to the GraphQL spec, nullable input fields are always optional:

Nullable types are always optional and non-null types are always required.

This release fixes the TypeError and now correctly treats nullable input fields as optional.

This release was contributed by @flo-zimmermann in #4568