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

Published by botberry 5 months ago

This release fixes a bug in release 0.227.3 where FragmentSpread nodes
were not resolving edges.

Releases contributed by @euriostigue via #3487

strawberry - 🍓 0.227.3

Published by botberry 6 months ago

This release adds an optimization to ListConnection such that only queries with
edges or pageInfo in their selected fields triggers resolve_edges.

This change is particularly useful for the strawberry-django extension's
ListConnectionWithTotalCount and the only selected field is totalCount. An
extraneous SQL query is prevented with this optimization.

Releases contributed by @euriostigue via #3480

strawberry - 🍓 0.227.2

Published by botberry 6 months ago

This release fixes a minor issue where the docstring for the relay util to_base64 described the return type incorrectly.

Releases contributed by @gbannerman via #3467

strawberry - 🍓 0.227.1

Published by botberry 6 months ago

This release fixes an issue where annotations on @strawberry.types were overridden
by our code. With release all annotations should be preserved.

This is useful for libraries that use annotations to introspect Strawberry types.

Releases contributed by @patrick91 via #3003

strawberry - 🍓 0.227.0

Published by botberry 6 months ago

This release improves the schema codegen, making it more robust and easier to
use.

It does this by introducing a directed acyclic graph for the schema codegen,
which should reduce the amount of edits needed to make the generated code work,
since it will be able to generate the code in the correct order (based on the
dependencies of each type).

Releases contributed by @patrick91 via #3116

strawberry - 🍓 0.226.2

Published by botberry 6 months ago

This release updates our Mypy plugin to add support for Pydantic >= 2.7.0

Releases contributed by @patrick91 via #3462

strawberry - 🍓 0.226.1

Published by botberry 6 months ago

This releases fixes a bug in the mypy plugin where the from_pydantic method
was not correctly typed.

Releases contributed by @Corentin-Br via #3368

strawberry - 🍓 0.226.0

Published by botberry 6 months ago

Starting with this release, any error raised from within schema
extensions will abort the operation and is returned to the client.

This corresponds to the way we already handle field extension errors
and resolver errors.

This is particular useful for schema extensions performing checks early
in the request lifecycle, for example:

class MaxQueryLengthExtension(SchemaExtension):
    MAX_QUERY_LENGTH = 8192

    async def on_operation(self):
        if len(self.execution_context.query) > self.MAX_QUERY_LENGTH:
            raise StrawberryGraphQLError(message="Query too large")
        yield
strawberry - 🍓 0.225.1

Published by botberry 6 months ago

This change fixes GET request queries returning a 400 if a content_type header is supplied

Releases contributed by @vethan via #3452

strawberry - 🍓 0.225.0

Published by botberry 6 months ago

This release adds support for using FastAPI APIRouter arguments in GraphQLRouter.

Now you have the opportunity to specify parameters such as tags, route_class,
deprecated, include_in_schema, etc:

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, tags=["graphql"])

app = FastAPI()
app.include_router(graphql_app, prefix="/graphql")

Releases contributed by @nparamonov via #3442

strawberry - 🍓 0.224.2

Published by botberry 6 months ago

This releases fixes a bug where schema extensions where not running a LIFO order.

Releases contributed by @nrbnlulu via #3416

strawberry - 🍓 0.224.1

Published by botberry 7 months ago

This release fixes a deprecation warning when using the Apollo Tracing
Extension.

Releases contributed by @coady via #3410

strawberry - 🍓 0.224.0

Published by botberry 7 months ago

This release adds support for using both Pydantic v1 and v2, when importing from
pydantic.v1.

This is automatically detected and the correct version is used.

Releases contributed by @patrick91 via #3426

strawberry - 🍓 0.223.0

Published by botberry 7 months ago

This release adds support for Apollo Federation in the schema codegen. Now you
can convert a schema like this:

extend schema
  @link(url: "https://specs.apollo.dev/federation/v2.3",
        import: ["@key", "@shareable"])

type Query {
  me: User
}

type User @key(fields: "id") {
  id: ID!
  username: String! @shareable
}

to a Strawberry powered schema like this:

import strawberry


@strawberry.type
class Query:
    me: User | None


@strawberry.federation.type(keys=["id"])
class User:
    id: strawberry.ID
    username: str = strawberry.federation.field(shareable=True)


schema = strawberry.federation.Schema(query=Query, enable_federation_2=True)

By running the following command:

strawberry schema-codegen example.graphql

Releases contributed by @patrick91 via #3417

strawberry - 🍓 0.222.0

Published by botberry 7 months ago

This release adds support for Apollo Federation v2.7 which includes the @authenticated, @requiresScopes, @policy directives, as well as the label argument for @override.
As usual, we have first class support for them in the strawberry.federation namespace, here's an example:

from strawberry.federation.schema_directives import Override


@strawberry.federation.type(
    authenticated=True,
    policy=[["client", "poweruser"], ["admin"]],
    requires_scopes=[["client", "poweruser"], ["admin"]],
)
class Product:
    upc: str = strawberry.federation.field(
        override=Override(override_from="mySubGraph", label="percent(1)")
    )

Releases contributed by @TygerTaco via #3420

strawberry - 🍓 0.221.1

Published by botberry 7 months ago

This release properly allows passing one argument to the Info class.

This is now fully supported:

import strawberry

from typing import TypedDict


class Context(TypedDict):
    user_id: str


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

Releases contributed by @patrick91 via #3419

strawberry - 🍓 0.221.0

Published by botberry 7 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

strawberry - 🍓 0.220.0

Published by botberry 8 months ago

This release adds support to allow passing connection_params as dictionary to GraphQLWebsocketCommunicator class when testing channels integration

Example

GraphQLWebsocketCommunicator(
    application=application,
    path="/graphql",
    connection_params={"username": "strawberry"},
)

Releases contributed by @selvarajrajkanna via #3403

strawberry - 🍓 0.219.2

Published by botberry 9 months ago

This releases updates the dependency of python-multipart to be at least 0.0.7 (which includes a security fix).

It also removes the upper bound for python-multipart so you can always install the latest version (if compatible) 😊

Releases contributed by @XChikuX via #3375

strawberry - 🍓 0.219.1

Published by botberry 9 months ago

  • Improved error message when supplying in incorrect before or after argument with using relay and pagination.
  • Add extra PR requirement in README.md

Releases contributed by @sdobbelaere via #3361

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