strawberry

A GraphQL library for Python that leverages type annotations 🍓

MIT License

Downloads
1.1M
Stars
3.8K
Committers
260
strawberry - Strawberry 0.13.0

Published by botberry over 5 years ago

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 - Strawberry 0.12.0

Published by botberry over 5 years ago

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 - Strawberry 0.11.0

Published by botberry over 5 years ago

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 - Strawberry 0.10.0

Published by botberry over 5 years ago

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 - Strawberry 0.9.1

Published by botberry over 5 years ago

Fixed logo on PyPI

strawberry - Strawberry 0.9.0

Published by botberry over 5 years ago

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 - Strawberry 0.8.0

Published by botberry over 5 years ago

Added support for renaming fields. Example usage:

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

Published by botberry over 5 years ago

Added support for declaring interface by using @strawberry.interface
Example:

@strawberry.interface
class Node:
    id: strawberry.ID
strawberry - Strawberry 0.6.0

Published by botberry over 5 years ago

This changes field to be lazy by default, allowing to use circular dependencies
when declaring types.

strawberry - Strawberry 0.5.6

Published by botberry over 5 years ago

Improve listing on pypi.org

Package Rankings
Top 1.15% on Pypi.org
Top 16.1% on Conda-forge.org
Badges
Extracted from project README
CircleCI Discord PyPI
Related Projects