strawberry

A GraphQL library for Python that leverages type annotations 🍓

MIT License

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

Published by botberry about 4 years ago

This release improves support for strawberry.enums when type checking with mypy.

strawberry - Strawberry 0.37.1

Published by botberry about 4 years ago

Fix ASGI view to call get_context during a websocket request

strawberry - Strawberry 0.37.0

Published by botberry about 4 years ago

Add support for adding a description to field arguments using the Annotated type:

from typing import Annotated

@strawberry.type
class Query:
    @strawberry.field
    def user_by_id(id: Annotated[str, strawberry.argument(description="The ID of the user")]) -> User:
        ...

which results in the following schema:

type Query {
  userById(
    """The ID of the user"""
    id: String
  ): User!
}

Note: if you are not using Python v3.9 or greater you will need to import Annotated from typing_extensions

strawberry - Strawberry 0.36.4

Published by botberry about 4 years ago

This release adds support for using strawberry.enum as a function with MyPy,
this is now valid typed code:

from enum import Enum

import strawberry

class IceCreamFlavour(Enum):
    VANILLA = "vanilla"
    STRAWBERRY = "strawberry"
    CHOCOLATE = "chocolate"

Flavour = strawberry.enum(IceCreamFlavour)
strawberry - Strawberry 0.36.3

Published by botberry about 4 years ago

Add __str__ to Schema to allow printing schema sdl with str(schema)

strawberry - Strawberry 0.36.2

Published by botberry about 4 years ago

Extend support for parsing isoformat datetimes,
adding a dependency on the dateutil library.
For example: "2020-10-12T22:00:00.000Z"
can now be parsed as a datetime with a UTC timezone.

strawberry - Strawberry 0.36.1

Published by botberry about 4 years ago

Add schema.introspect() method to return introspection result of the schema.
This might be useful for tools like apollo codegen or graphql-voyager which
expect a full json representation of the schema

strawberry - Strawberry 0.36.0

Published by botberry about 4 years ago

This releases adds a new extension for OpenTelemetry.

import asyncio

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
    ConsoleSpanExporter,
    SimpleExportSpanProcessor,
)

import strawberry
from strawberry.extensions.tracing import OpenTelemetryExtension


trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(
    SimpleExportSpanProcessor(ConsoleSpanExporter())
)


@strawberry.type
class User:
    name: str


@strawberry.type
class Query:
    @strawberry.field
    async def user(self, name: str) -> User:
        await asyncio.sleep(0.1)
        return User(name)


schema = strawberry.Schema(Query, extensions=[OpenTelemetryExtension])
strawberry - Strawberry 0.35.5

Published by botberry about 4 years ago

This release disables tracing for default resolvers and introspection queries

strawberry - Strawberry 0.35.4

Published by botberry about 4 years ago

This releases allows UNSET to be used anywhere and prevents mypy to report an error.

strawberry - Strawberry 0.35.3

Published by botberry about 4 years ago

This releases adds support for strawberry.union inside mypy.

strawberry - Strawberry 0.35.2

Published by botberry about 4 years ago

This release fixes an issue with the extension runner and async resolvers

strawberry - Strawberry 0.35.1

Published by botberry about 4 years ago

Fixed bug where you couldn't use the same Union type multiple times in a schema.

strawberry - Strawberry 0.35.0

Published by botberry about 4 years ago

Added strawberry.Private type to mark fields as "private" so they don't show up in the GraphQL schema.

Example:

import strawberry

@strawberry.type
class User:
    age: strawberry.Private[int]

    @strawberry.field
    def age_in_months(self) -> int:
        return self.age * 12
strawberry - Strawberry 0.34.2

Published by botberry about 4 years ago

Fix typo in type_resolver.py

strawberry - Strawberry 0.34.1

Published by botberry about 4 years ago

This release fixes an issue with mypy when doing the following:

import strawberry

@strawberry.type
class User:
    name: str = strawberry.field(description='Example')
strawberry - Strawberry 0.34.0

Published by botberry about 4 years ago

This release adds support for Apollo Tracing and support for creating Strawberry
extensions, here's how you can enable Apollo tracing:

from strawberry.extensions.tracing import ApolloTracingExtension

schema = strawberry.Schema(query=Query, extensions=[ApolloTracingExtension])

And here's an example of custom extension:

from strawberry.extensions import Extension

class MyExtension(Extension):
    def get_results(self):
        return {
            "example": "this is an example for an extension"
        }

schema = strawberry.Schema(query=Query, extensions=[MyExtension])
strawberry - Strawberry 0.33.1

Published by botberry about 4 years ago

This release fixes an issue when trying to print a type
with a UNSET default value

strawberry - Strawberry 0.33.0

Published by botberry about 4 years ago

  • UnionDefinition has been renamed to StrawberryUnion
  • strawberry.union now returns an instance of StrawberryUnion instead of a
    dynamically generated class instance with a _union_definition attribute of
    type UnionDefinition.
strawberry - Strawberry 0.32.4

Published by botberry about 4 years ago

This release adds the py.typed file for better mypy support.

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