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

Published by botberry almost 3 years ago

This release adds a GraphQLTestClient. It hides the http request's details and asserts that there are no errors in the response (you can always disable this behavior by passing asserts_errors=False). This makes it easier to test queries and makes your tests cleaner.

If you are using pytest you can add a fixture in conftest.py

import pytest

from django.test.client import Client

from strawberry.django.test import GraphQLTestClient


@pytest.fixture()
def graphql_client():
    yield GraphQLTestClient(Client())

And use it everywere in your test methods

def test_strawberry(graphql_client):
    query = """
        query Hi($name: String!) {
            hi(name: $name)
        }
    """

    result = graphql_client.query(query, variables={"name": "Marcotte"})

    assert result.data == {"hi": "Hi Marcotte!"}

It can be used to test the file uploads as well

from django.core.files.uploadedfile import SimpleUploadedFile


def test_upload(graphql_client):
    f = SimpleUploadedFile("file.txt", b"strawberry")
    query = """
        mutation($textFile: Upload!) {
            readText(textFile: $textFile)
        }
    """

    response = graphql_client.query(
        query=query,
        variables={"textFile": None},
        files={"textFile": f},
    )

    assert response.data["readText"] == "strawberry"
strawberry - 🍓 0.90.3

Published by botberry almost 3 years ago

This release fixes an issue that prevented using enums as
arguments for generic types inside unions.

strawberry - 🍓 0.90.2

Published by botberry almost 3 years ago

This release fixes the message of InvalidFieldArgument to properly show the field's name in the error message.

strawberry - 🍓 0.90.1

Published by botberry almost 3 years ago

This release fixes an issue that prevented using classmethods and staticmethods as resolvers

import strawberry

@strawberry.type
class Query:
    @strawberry.field
    @staticmethod
    def static_text() -> str:
        return "Strawberry"

    @strawberry.field
    @classmethod
    def class_name(cls) -> str:
        return cls.__name__
strawberry - 🍓 0.90.0

Published by botberry almost 3 years ago

This release improves type checking support for strawberry.union and now allows
to use unions without any type issue, like so:

@strawberry.type
class User:
    name: str

@strawberry.type
class Error:
    message: str

UserOrError = strawberry.union("UserOrError", (User, Error))

x: UserOrError = User(name="Patrick")
strawberry - 🍓 0.89.2

Published by botberry almost 3 years ago

Fix init of Strawberry types from pydantic by skipping fields that have resolvers.

strawberry - 🍓 0.89.1

Published by botberry almost 3 years ago

This release fixes an issubclass test failing for Literals in the experimental pydantic integration.

strawberry - 🍓 0.89.0

Published by botberry almost 3 years ago

This release changes how strawberry.Private is implemented to
improve support for type checkers.

strawberry - 🍓 0.88.0

Published by botberry almost 3 years ago

This release adds support for AWS Chalice. A framework for deploying serverless applications using AWS.

A view for aws chalice has been added to the strawberry codebase.
This view embedded in a chalice app allows anyone to get a GraphQL API working and hosted on AWS in minutes using a serverless architecture.

strawberry - 🍓 0.87.3

Published by botberry almost 3 years ago

This release fixes the naming generation of generics when
passing a generic type to another generic, like so:

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

@strawberry.type
class Connection(Generic[T]):
    edges: List[T]

Connection[Edge[int]]
strawberry - 🍓 0.87.2

Published by botberry almost 3 years ago

This releases updates the typing_extension dependency to latest version.

strawberry - 🍓 0.87.1

Published by botberry almost 3 years ago

This release renames an internal exception from NotAnEnum to ObjectIsNotAnEnumError.

strawberry - 🍓 0.87.0

Published by botberry almost 3 years ago

This release changes how we handle GraphQL names. It also introduces a new
configuration option called name_converter. This option allows you to specify
a custom NameConverter to be used when generating GraphQL names.

This is currently not documented because the API will change slightly in future
as we are working on renaming internal types.

This release also fixes an issue when creating concrete types from generic when
passing list objects.

strawberry - 🍓 0.86.1

Published by botberry almost 3 years ago

This release fixes our MyPy plugin and re-adds support
for typechecking classes created with the apollo federation decorator.

strawberry - 🍓 0.86.0

Published by botberry almost 3 years ago

Add on_executing_* hooks to extensions to allow you to override the execution phase of a GraphQL operation.

strawberry - 🍓 0.85.1

Published by botberry almost 3 years ago

This release fixes an issue with schema directives not
being printed correctly.

strawberry - 🍓 0.85.0

Published by botberry almost 3 years ago

This release introduces initial support for schema directives and
updates the federation support to use that.

Full support will be implemented in future releases.

strawberry - 🍓 0.84.4

Published by botberry almost 3 years ago

Field definition uses output of default_factory as the GraphQL default_value.

a_field: list[str] = strawberry.field(default_factory=list)
aField: [String!]! = []
strawberry - 🍓 0.84.3

Published by botberry about 3 years ago

This release fixed the typing support for Pyright.

strawberry - 🍓 0.84.2

Published by botberry about 3 years ago

This release adds an extra dependency for FastAPI to prevent
it being downloaded even when not needed.

To install Strawberry with FastAPI support you can do:

pip install 'strawberry-graphql[fastapi]'
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