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.138.0

Published by botberry almost 2 years ago

This release adds support for generic in arguments, see the following example:

T = TypeVar('T')

@strawberry.type
class Node(Generic[T]):
   @strawberry.field
   def data(self, arg: T) -> T:  # `arg` is also generic
       return arg
strawberry - 🍓 0.137.1

Published by botberry almost 2 years ago

Allowed CustomScalar | None syntax for python >= 3.10.

strawberry - 🍓 0.137.0

Published by botberry almost 2 years ago

This release fixes errors when using Union-of-lazy-types

strawberry - 🍓 0.136.0

Published by botberry almost 2 years ago

This release refactors the chalice integration in order to keep it consistent with
the other integrations.

Deprecation:

Passing render_graphiql is now deprecated, please use graphiql instead.

New features:

  • You can now return a custom status by using info.context["response"].status_code = 418
  • You can enabled/disable queries via get using allow_queries_via_get (defaults to True)

Changes:

Trying to access /graphql via a browser and with graphiql set to False will return a 404.

strawberry - 🍓 0.135.0

Published by botberry almost 2 years ago

This release adds a new MaskErrors extension that can be used to hide error
messages from the client to prevent exposing sensitive details. By default it
masks all errors raised in any field resolver.

import strawberry
from strawberry.extensions import MaskErrors

schema = strawberry.Schema(
    Query,
    extensions=[
        MaskErrors(),
    ]
)
strawberry - 🍓 0.134.5

Published by botberry about 2 years ago

This release improves the error message that you get when trying
to use an enum that hasn't been decorated with @strawberry.enum
inside a type's field.

strawberry - 🍓 0.134.4

Published by botberry about 2 years ago

This release adds support for printing schema directives on an input type object, for example the following schema:

@strawberry.schema_directive(locations=[Location.INPUT_FIELD_DEFINITION])
class RangeInput:
    min: int
    max: int

@strawberry.input
class CreateUserInput:
    name: str
    age: int = strawberry.field(directives=[RangeInput(min=1, max=100)])

prints the following:

directive @rangeInput(min: Int!, max: Int!) on INPUT_FIELD_DEFINITION

input Input @sensitiveInput(reason: "GDPR") {
  firstName: String!
  age: Int! @rangeInput(min: 1, max: 100)
}
strawberry - 🍓 0.134.3

Published by botberry about 2 years ago

This release fixes an issue that prevented using strawberry.lazy with relative paths.

The following should work now:

@strawberry.type
class TypeA:
    b: Annotated["TypeB", strawberry.lazy(".type_b")]
strawberry - 🍓 0.134.2

Published by botberry about 2 years ago

This release adds pyupgrade to our CI and includes some minor changes to keep our codebase modern.

strawberry - 🍓 0.134.1

Published by botberry about 2 years ago

This release fixes an issue that prevented using lazy types inside
generic types.

The following is now allowed:

T = TypeVar("T")

TypeAType = Annotated["TypeA", strawberry.lazy("tests.schema.test_lazy.type_a")]

@strawberry.type
class Edge(Generic[T]):
    node: T

@strawberry.type
class Query:
    users: Edge[TypeAType]
strawberry - 🍓 0.134.0

Published by botberry about 2 years ago

These release allow you to define a different url in the GraphQLTestClient, the default is "/graphql/".

Here's an example with Starlette client:

import pytest

from starlette.testclient import TestClient
from strawberry.asgi.test import GraphQLTestClient


@pytest.fixture
def graphql_client() -> GraphQLTestClient:
    return GraphQLTestClient(TestClient(app, base_url="http://localhost:8000"), url="/api/")
strawberry - 🍓 0.133.7

Published by botberry about 2 years ago

This release fixes a type issue when passing scalar_overrides to strawberry.Schema

strawberry - 🍓 0.133.6

Published by botberry about 2 years ago

Fix support for arguments where arg.type=LazyType["EnumType"]

strawberry - 🍓 0.133.5

Published by botberry about 2 years ago

Updated unset import, from strawberry.arguments to strawberry.unset in codebase.

This will prevent strawberry from triggering its own warning on deprecated imports.

strawberry - 🍓 0.133.4

Published by botberry about 2 years ago

This release fixes the type of strawberry.federation.field,
this will prevent errors from mypy and pyright when doing the following:

@strawberry.federation.type(keys=["id"])
class Location:
    id: strawberry.ID

    # the following field was reporting an error in mypy and pylance
    celestial_body: CelestialBody = strawberry.federation.field(
        resolver=resolve_celestial_body
    )
strawberry - 🍓 0.133.3

Published by botberry about 2 years ago

This release allows to create a federation schema without having to pass a
Query type. This is useful when your schema only extends some types without
adding any additional root field.

@strawberry.federation.type(keys=["id"])
class Location:
    id: strawberry.ID
    name: str = strawberry.federation.field(override="start")

schema = strawberry.federation.Schema(types=[Location])
strawberry - 🍓 0.133.2

Published by botberry about 2 years ago

This release fixes an issue with strawberry.federation.field that
prevented instantiating field when passing a resolver function.

strawberry - 🍓 0.133.1

Published by botberry about 2 years ago

This release fixes an issue that prevented using strawberry.field with
UNSET as the default value.

strawberry - 🍓 0.133.0

Published by botberry about 2 years ago

Reduce the number of required dependencies, by marking Pygments and python-multipart as optional. These dependencies are still necessary for some functionality, and so users of that functionality need to ensure they're installed, either explicitly or via an extra:

  • Pygments is still necessary when using Strawberry in debug mode, and is included in the strawberry[debug-server] extra.
  • python-multipart is still necessary when using strawberry.file_uploads.Upload with FastAPI or Starlette, and is included in the strawberry[fastapi] and strawberry[asgi] extras, respectively.

There is now also the strawberry[cli] extra to support commands like strawberry codegen and strawberry export-schema.

strawberry - 🍓 0.132.1

Published by botberry about 2 years ago

Improve resolving performance by avoiding extra calls for basic fields.

This change improves performance of resolving a query by skipping Info
creation and permission checking for fields that don't have a resolver
or permission classes. In local benchmarks it improves performance of large
results by ~14%.

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