Strawberry-graphql

Latest version: v0.235.0

Safety actively analyzes 638430 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 36 of 122

0.157.0

Not secure
--------------------

This releases adds support for Apollo Federation 2.1, 2.2 and 2.3.

This includes support for `composeDirective` and `interfaceObject`,
we expose directives for both, but we also have shortcuts, for example
to use `composeDirective` with a custom schema directive, you can do
the following:

python
strawberry.federation.schema_directive(
locations=[Location.OBJECT], name="cacheControl", compose=True
)
class CacheControl:
max_age: int


The `compose=True` makes so that this directive is included in the supergraph
schema.

For `interfaceObject` we introduced a new `strawberry.federation.interface_object`
decorator. This works like `strawberry.federation.type`, but it adds, the appropriate
directive, for example:

python
strawberry.federation.interface_object(keys=["id"])
class SomeInterface:
id: strawberry.ID


generates the following type:

graphql
type SomeInterface key(fields: "id") interfaceObject {
id: ID!
}


Contributed by [Patrick Arminio](https://github.com/patrick91) via [PR #2549](https://github.com/strawberry-graphql/strawberry/pull/2549/)

0.156.4

Not secure
--------------------

This release fixes a regression introduce in version 0.156.2 that
would make Mypy throw an error in the following code:

python
import strawberry


strawberry.type
class Author:
name: str


strawberry.type
class Query:
strawberry.field
async def get_authors(self) -> list[Author]:
return [Author(name="Michael Crichton")]


Contributed by [Patrick Arminio](https://github.com/patrick91) via [PR #2535](https://github.com/strawberry-graphql/strawberry/pull/2535/)

0.156.3

Not secure
--------------------

0.156.2

Not secure
--------------------

This release updates the typing for the resolver argument in
`strawberry.field`i to support async resolvers.
This means that now you won't get any type
error from Pyright when using async resolver, like the following example:

python
import strawberry


async def get_user_age() -> int:
return 0


strawberry.type
class User:
name: str
age: int = strawberry.field(resolver=get_user_age)


Contributed by [Patrick Arminio](https://github.com/patrick91) via [PR #2528](https://github.com/strawberry-graphql/strawberry/pull/2528/)

0.156.1

Not secure
--------------------

Add `GraphQLWebsocketCommunicator` for testing websockets on channels.
i.e:

python
import pytest
from strawberry.channels.testing import GraphQLWebsocketCommunicator
from myapp.asgi import application


pytest.fixture
async def gql_communicator():
async with GraphQLWebsocketCommunicator(
application=application, path="/graphql"
) as client:
yield client


async def test_subscribe_echo(gql_communicator):
async for res in gql_communicator.subscribe(
query='subscription { echo(message: "Hi") }'
):
assert res.data == {"echo": "Hi"}


Contributed by [ניר](https://github.com/nrbnlulu) via [PR #2458](https://github.com/strawberry-graphql/strawberry/pull/2458/)

0.156.0

Not secure
--------------------

This release adds support for specialized generic types.
Before, the following code would give an error, saying that `T` was not
provided to the generic type:

python
strawberry.type
class Foo(Generic[T]):
some_var: T


strawberry.type
class IntFoo(Foo[int]): ...


strawberry.type
class Query:
int_foo: IntFoo


Also, because the type is already specialized, `Int` won't get inserted to its name,
meaning it will be exported to the schema with a type name of `IntFoo` and not
`IntIntFoo`.

For example, this query:

python
strawberry.type
class Query:
int_foo: IntFoo
str_foo: Foo[str]


Will generate a schema like this:

graphql
type IntFoo {
someVar: Int!
}

type StrFoo {
someVar: String!
}

type Query {
intFoo: IntFoo!
strfoo: StrFoo!
}


Contributed by [Thiago Bellini Ribeiro](https://github.com/bellini666) via [PR #2517](https://github.com/strawberry-graphql/strawberry/pull/2517/)

Page 36 of 122

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.