strawberry

A GraphQL library for Python that leverages type annotations 🍓

MIT License

Downloads
1.1M
Stars
3.8K
Committers
260

Bot releases are hidden (Show)

strawberry - 🍓 0.84.1

Published by botberry about 3 years ago

This release fixes the merge_types type signature.

strawberry - 🍓 0.84.0

Published by botberry about 3 years ago

This release adds support for FastAPI integration using APIRouter.

import strawberry

from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter

@strawberry.type
class Query:
    @strawberry.field
    def hello(self) -> str:
        return "Hello World"

schema = strawberry.Schema(Query)

graphql_app = GraphQLRouter(schema)

app = FastAPI()
app.include_router(graphql_app, prefix="/graphql")
strawberry - 🍓 0.83.6

Published by botberry about 3 years ago

Improve help texts for CLI to work better on ZSH.

strawberry - 🍓 0.83.5

Published by botberry about 3 years ago

Errors encountered in subscriptions will now be logged to the strawberry.execution logger as errors encountered in Queries and Mutations are. <3

strawberry - 🍓 0.83.4

Published by botberry about 3 years ago

Add logic to convert arguments of type LazyType.

strawberry - 🍓 0.83.3

Published by botberry about 3 years ago

This release fixes a bug where passing scalars in the scalar_overrides
parameter wasn't being applied consistently.

strawberry - 🍓 0.83.2

Published by botberry about 3 years ago

Pydantic fields' description are now copied to the GraphQL schema

import pydantic
import strawberry

class UserModel(pydantic.BaseModel):
    age: str = pydantic.Field(..., description="Description")

@strawberry.experimental.pydantic.type(UserModel)
class User:
    age: strawberry.auto
type User {
  """Description"""
  age: String!
}
strawberry - 🍓 0.83.1

Published by botberry about 3 years ago

We now run our tests against Windows during CI!

strawberry - 🍓 0.83.0

Published by botberry about 3 years ago

Add a shortcut to merge queries, mutations. E.g.:

import strawberry
from strawberry.tools import merge_types


@strawberry.type
class QueryA:
    ...


@strawberry.type
class QueryB:
    ...


ComboQuery = merge_types("ComboQuery", (QueryB, QueryA))
schema = strawberry.Schema(query=ComboQuery)
strawberry - 🍓 0.82.2

Published by botberry about 3 years ago

Makes the GraphQLSchema instance accessible from resolvers via the info parameter.

strawberry - 🍓 0.82.1

Published by botberry about 3 years ago

Fix bug where errors thrown in the on_parse_* extension hooks were being
swallowed instead of being propagated.

strawberry - 🍓 0.82.0

Published by botberry about 3 years ago

Adds support for the auto type annotation described in #1192 to the Pydantic
integration, which allows a user to define the list of fields without having to
re-specify the type themselves. This gives better editor and type checker
support. If you want to expose every field you can instead pass
all_fields=True to the decorators and leave the body empty.

import pydantic
import strawberry
from strawberry.experimental.pydantic import auto

class User(pydantic.BaseModel):
    age: int
    password: str


@strawberry.experimental.pydantic.type(User)
class UserType:
    age: auto
    password: auto
strawberry - 🍓 0.81.0

Published by botberry about 3 years ago

This release adds a safety check on strawberry.type, strawberry.input and
strawberry.interface decorators. When you try to use them with an object that is not a
class, you will get a nice error message:
strawberry.type can only be used with classes

strawberry - 🍓 0.80.2

Published by botberry about 3 years ago

Add Starlette to the integrations section on the documentation.

strawberry - 🍓 0.80.1

Published by botberry about 3 years ago

This release add support for the upcoming python 3.10 and it adds support
for the new union syntax, allowing to declare unions like this:

import strawberry

@strawberry.type
class User:
    name: str

@strawberry.type
class Error:
    code: str

@strawberry.type
class Query:
    find_user: User | Error
strawberry - 🍓 0.80.0

Published by botberry about 3 years ago

This release adds support for the graphql-transport-ws GraphQL over WebSocket
protocol. Previously Strawberry only supported the legacy graphql-ws protocol.

Developers can decide which protocols they want to accept. The following example shows
how to do so using the ASGI integration. By default, both protocols are accepted.
Take a look at our GraphQL subscription documentation to learn more.

from strawberry.asgi import GraphQL
from strawberry.subscriptions import GRAPHQL_TRANSPORT_WS_PROTOCOL
from api.schema import schema


app = GraphQL(schema, subscription_protocols=[GRAPHQL_TRANSPORT_WS_PROTOCOL])
strawberry - 🍓 0.79.0

Published by botberry about 3 years ago

Nests the resolver under the correct span; prior to this change your span would have looked something like:

GraphQL Query
  GraphQL Parsing
  GraphQL Validation
  my_resolver
  my_span_of_interest #1
    my_sub_span_of_interest #2

After this change you'll have:

GraphQL Query
  GraphQL Parsing
  GraphQL Validation
  GraphQL Resolving: my_resolver
    my_span_of_interest #1
      my_sub_span_of_interest #2
strawberry - 🍓 0.78.2

Published by botberry about 3 years ago

Enhances strawberry.extensions.tracing.opentelemetry to include spans for the Parsing and Validation phases of request handling. These occur before your resovler is called, so now you can see how much time those phases take up!

strawberry - 🍓 0.78.1

Published by botberry about 3 years ago

Fix extensions argument type definition on strawberry.Schema

strawberry - 🍓 0.78.0

Published by botberry about 3 years ago

This release introduces some brand new extensions to help improve the
performance of your GraphQL server:

  • ParserCache - Cache the parsing of a query in memory
  • ValidationCache - Cache the validation step of execution

For complicated queries these 2 extensions can improve performance by over 50%!

Example:

import strawberry
from strawberry.extensions import ParserCache, ValidationCache

schema = strawberry.Schema(
  Query,
  extensions=[
    ParserCache(),
    ValidationCache(),
  ]
)

This release also removes the validate_queries and validation_rules
parameters on the schema.execute* methods in favour of using the
DisableValidation and AddValidationRule extensions.

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