pypi strawberry-graphql 0.221.0
🍓 0.221.0

latest releases: 0.235.0, 0.234.3, 0.234.2...
2 months ago

This release improves the Info type, by adding support for default TypeVars
and by exporting it from the main module. This makes it easier to use Info in
your own code, without having to import it from strawberry.types.info.

New export

By exporting Info from the main module, now you can do the follwing:

import strawberry


@strawberry.type
class Query:
    @strawberry.field
    def info(self, info: strawberry.Info) -> str:
        # do something with info
        return "hello"

Default TypeVars

The Info type now has default TypeVars, so you can use it without having to
specify the type arguments, like we did in the example above. Make sure to use
the latest version of Mypy or Pyright for this. It also means that you can only
pass one value to it if you only care about the context type:

import strawberry

from .context import Context


@strawberry.type
class Query:
    @strawberry.field
    def info(self, info: strawberry.Info[Context]) -> str:
        return info.context.user_id

Releases contributed by @patrick91 via #3418

Don't miss a new strawberry-graphql release

NewReleases is sending notifications on new releases.