A GraphQL library for Python that leverages type annotations 🍓
MIT License
Bot releases are hidden (Show)
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"
Published by botberry almost 3 years ago
This release fixes an issue that prevented using enums as
arguments for generic types inside unions.
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.
Published by botberry almost 3 years ago
This release fixes an issue that prevented using classmethod
s and staticmethod
s 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__
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")
Published by botberry almost 3 years ago
Fix init of Strawberry types from pydantic by skipping fields that have resolvers.
Published by botberry almost 3 years ago
This release fixes an issubclass test failing for Literal
s in the experimental pydantic
integration.
Published by botberry almost 3 years ago
This release changes how strawberry.Private
is implemented to
improve support for type checkers.
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.
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]]
Published by botberry almost 3 years ago
This releases updates the typing_extension
dependency to latest version.
Published by botberry almost 3 years ago
This release renames an internal exception from NotAnEnum
to ObjectIsNotAnEnumError
.
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.
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.
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.
Published by botberry almost 3 years ago
This release fixes an issue with schema directives not
being printed correctly.
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.
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!]! = []
Published by botberry about 3 years ago
This release fixed the typing support for Pyright.
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]'