Skip to content

Releases: strawberry-graphql/strawberry

Strawberry 0.13.3

23 Jul 07:14
Compare
Choose a tag to compare

Fix field initialization not allowed when using strawberry.field in an input type

@strawberry.input
class Say:
    what = strawberry.field(is_input=True)

Strawberry 0.13.2

18 Jul 20:07
Compare
Choose a tag to compare

Allow the usage of Union types in the mutations

@strawberry.type
class A:
    x: int

@strawberry.type
class B:
    y: int

@strawberry.type
class Mutation:
    @strawberry.mutation
    def hello(self, info) -> Union[A, B]:
        return B(y=5)

schema = strawberry.Schema(query=A, mutation=Mutation)

query = """
mutation {
    hello {
        __typename

        ... on A {
            x
        }

        ... on B {
            y
        }
    }
}
"""

Strawberry 0.13.1

17 Jul 18:03
Compare
Choose a tag to compare

Fix missing fields when extending a class, now we can do this:

@strawberry.type
class Parent:
    cheese: str = "swiss"

    @strawberry.field
    def friend(self, info) -> str:
        return 'food'

@strawberry.type
class Schema(Parent):
    cake: str = "made_in_swiss"

Strawberry 0.13.0

16 Jul 06:42
Compare
Choose a tag to compare

This release adds field support for permissions

import strawberry

from strawberry.permission import BasePermission

class IsAdmin(BasePermission):
    message = "You are not authorized"

    def has_permission(self, info):
      return False

@strawberry.type
class Query:
    @strawberry.field(permission_classes=[IsAdmin])
    def hello(self, info) -> str:
      return "Hello"

Strawberry 0.12.0

25 Jun 17:39
Compare
Choose a tag to compare

This releases adds support for ASGI 3.0

from strawberry.asgi import GraphQL
from starlette.applications import Starlette

graphql_app = GraphQL(schema_module.schema, debug=True)

app = Starlette(debug=True)
app.add_route("/graphql", graphql_app)
app.add_websocket_route("/graphql", graphql_app)

Strawberry 0.11.0

07 Jun 21:58
Compare
Choose a tag to compare

Added support for optional fields with default arguments in the GraphQL schema when default arguments are passed to the resolver.

Example:

@strawberry.type
class Query:
   @strawberry.field
   def hello(self, info, name: str = "world") -> str:
       return name
type Query {
    hello(name: String = "world"): String
}

Strawberry 0.10.0

28 May 08:38
Compare
Choose a tag to compare

Fixed issue that was prevent usage of InitVars.
Now you can safely use InitVar to prevent fields from showing up in the schema:

@strawberry.type
class Category:
    name: str
    id: InitVar[str]

@strawberry.type
class Query:
    @strawberry.field
    def category(self, info) -> Category:
        return Category(name="example", id="123")

Strawberry 0.9.1

25 May 11:37
Compare
Choose a tag to compare

Fixed logo on PyPI

Strawberry 0.9.0

24 May 23:44
Compare
Choose a tag to compare

Added support for passing resolver functions

def resolver(root, info, par: str) -> str:
    return f"hello {par}"

@strawberry.type
class Query:
    example: str = strawberry.field(resolver=resolver)

Also we updated some of the dependencies of the project

Strawberry 0.8.0

09 May 14:43
3914261
Compare
Choose a tag to compare

Added support for renaming fields. Example usage:

@strawberry.type
class Query:
    example: str = strawberry.field(name='test')