pypi strawberry-graphql 0.291.0
🍓 0.291.0

2 hours ago

Adds a graphql_type parameter to strawberry.argument that allows you
to explicitly override the GraphQL type of an argument, useful for static typing
when the Python type differs from the desired GraphQL type.

For example:

BigInt = strawberry.scalar(
    int, name="BigInt", serialize=lambda v: str(v), parse_value=lambda v: int(v)
)


@strawberry.type
class Query:
    @strawberry.field()
    def username(
        self, user_id: Annotated[int, strawberry.argument(graphql_type=BigInt)]
    ) -> str:
        return "foobar"


schema = strawberry.Schema(Query)

str(
    schema
) == """
scalar BigInt

type Query {
  username(userId: BigInt!): String!
}
"""

Releases contributed by @thearchitector via #4067

Don't miss a new strawberry-graphql release

NewReleases is sending notifications on new releases.