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

Published by botberry over 2 years ago

This release adds support for Apollo Federation 2 directives:

  • @shareable
  • @tag
  • @override
  • @inaccessible

This release does not add support for the @link directive.

This release updates the @key directive to align with Apollo Federation 2 updates.

See the below code snippet and/or the newly-added test cases for examples on how to use the new directives.
The below snippet demonstrates the @override directive.

import strawberry
from typing import List

@strawberry.interface
class SomeInterface:
    id: strawberry.ID

@strawberry.federation.type(keys=["upc"], extend=True)
class Product(SomeInterface):
    upc: str = strawberry.federation.field(external=True, override=["mySubGraph"])

@strawberry.federation.type
class Query:
    @strawberry.field
    def top_products(self, first: int) -> List[Product]:
        return []

schema = strawberry.federation.Schema(query=Query)

should return:

extend type Product implements SomeInterface @key(fields: "upc", resolvable: "True") {
  id: ID!
  upc: String! @external @override(from: "mySubGraph")
}

type Query {
  _service: _Service!
  _entities(representations: [_Any!]!): [_Entity]!
  topProducts(first: Int!): [Product!]!
}

interface SomeInterface {
  id: ID!
}

scalar _Any

union _Entity = Product

type _Service {
  sdl: String!
}
strawberry - 🍓 0.110.0

Published by botberry over 2 years ago

This release adds support for passing a custom name to schema directives fields,
by using strawberry.directive_field.

import strawberry

@strawberry.schema_directive(locations=[Location.FIELD_DEFINITION])
class Sensitive:
    reason: str = strawberry.directive_field(name="as")
    real_age_2: str = strawberry.directive_field(name="real_age")

@strawberry.type
class Query:
    first_name: str = strawberry.field(
        directives=[Sensitive(reason="GDPR", real_age_2="42")]
    )

should return:

type Query {
    firstName: String! @sensitive(as: "GDPR", real_age: "42")
}
strawberry - 🍓 0.109.1

Published by botberry over 2 years ago

This release adds support for Mypy 0.950

strawberry - 🍓 0.109.0

Published by botberry over 2 years ago

Changed the location of UNSET from arguments.py to unset.py. UNSET can now also be imported directly from strawberry. Deprecated the is_unset method in favor of the builtin is operator:

from strawberry import UNSET
from strawberry.arguments import is_unset  # old

a = UNSET

assert a is UNSET  # new
assert is_unset(a)  # old

Further more a new subsection to the docs was added explaining this.

strawberry - 🍓 0.108.3

Published by botberry over 2 years ago

Fixes a bug when converting pydantic models with NewTypes in a List.
This no longers causes an exception.

from typing import List, NewType
from pydantic import BaseModel
import strawberry

password = NewType("password", str)

class User(BaseModel):
   passwords: List[password]


@strawberry.experimental.pydantic.type(User)
class UserType:
   passwords: strawberry.auto

strawberry - 🍓 0.108.2

Published by botberry over 2 years ago

Fixes mypy type inference when using @strawberry.experimental.pydantic.input
and @strawberry.experimental.pydantic.interface decorators

strawberry - 🍓 0.108.1

Published by botberry over 2 years ago

Refactoring: Move enum deserialization logic from convert_arguments to CustomGraphQLEnumType

strawberry - 🍓 0.108.0

Published by botberry over 2 years ago

Added support for deprecating Enum values with deprecation_reason while using strawberry.enum_value instead of string definition.

@strawberry.enum
class IceCreamFlavour(Enum):
    VANILLA = strawberry.enum_value("vanilla")
    STRAWBERRY = strawberry.enum_value(
        "strawberry", deprecation_reason="We ran out"
    )
    CHOCOLATE = "chocolate"
strawberry - 🍓 0.107.1

Published by botberry over 2 years ago

This release fixes an issue in the previous release where requests using query params did not support passing variable values. Variables passed by query params are now parsed from a string to a dictionary.

strawberry - 🍓 0.107.0

Published by botberry over 2 years ago

This release adds support in all our integration for queries via GET requests.
This behavior is enabled by default, but you can disable it by passing
allow_queries_via_get=False to the constructor of the integration of your
choice.

For security reason only queries are allowed via GET requests.

strawberry - 🍓 0.106.3

Published by botberry over 2 years ago

Correctly parse Decimal scalar types to avoid floating point errors

strawberry - 🍓 0.106.2

Published by botberry over 2 years ago

Allow all data types in Schema(types=[...])

strawberry - 🍓 0.106.1

Published by botberry over 2 years ago

This release fixes a number of problems with single-result-operations over
graphql-transport-ws protocol

  • operation IDs now share the same namespace as streaming operations
    meaning that they cannot be reused while the others are in operation

  • single-result-operations now run as tasks meaning that messages related
    to them can be overlapped with other messages on the websocket.

  • single-result-operations can be cancelled with the complete message.

  • IDs for single result and streaming result operations are now released
    once the operation is done, allowing them to be re-used later, as well as
    freeing up resources related to previous requests.

strawberry - 🍓 0.106.0

Published by botberry over 2 years ago

This release adds an implementation of the GraphQLTestClient for the aiohttp integration (in addition to the existing asgi and Django support). It hides the HTTP request's details and verifies that there are no errors in the response (this behavior can be disabled 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 strawberry.aiohttp.test.client import GraphQLTestClient

@pytest.fixture
def graphql_client(aiohttp_client, myapp):
    yield GraphQLTestClient(aiohttp_client(myapp))

And use it everywhere in your tests

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

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

    assert result.data == {"hi": "Hi 🍓!"}
strawberry - 🍓 0.105.1

Published by botberry over 2 years ago

This release fixes a bug in the codegen that marked optional unions
as non optional.

strawberry - 🍓 0.105.0

Published by botberry over 2 years ago

This release adds support for passing json_encoder and json_dumps_params to Sanic's view.

from strawberry.sanic.views import GraphQLView

from api.schema import Schema

app = Sanic(__name__)

app.add_route(
    GraphQLView.as_view(
        schema=schema,
        graphiql=True,
        json_encoder=CustomEncoder,
        json_dumps_params={},
    ),
    "/graphql",
)
strawberry - 🍓 0.104.4

Published by botberry over 2 years ago

Allow use of AsyncIterator and AsyncIterable generics to annotate return
type of subscription resolvers.

strawberry - 🍓 0.104.3

Published by botberry over 2 years ago

Exeptions from handler functions in graphql_transport_ws are no longer
incorrectly caught and classified as message parsing errors.

strawberry - 🍓 0.104.2

Published by botberry over 2 years ago

Drop support for Django < 3.2.

strawberry - 🍓 0.104.1

Published by botberry over 2 years ago

This release adds support for aliased fields when doing codegen.

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