Strawberry-graphql

Latest version: v0.235.0

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

Scan your dependencies

Page 39 of 122

0.151.0

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

This PR adds a new `graphql_type` parameter to strawberry.field that allows you
to explicitly set the field type. This parameter will take preference over the
resolver return type and the class field type.

For example:

python
strawberry.type
class Query:
a: float = strawberry.field(graphql_type=str)
b = strawberry.field(graphql_type=int)

strawberry.field(graphql_type=float)
def c(self) -> str:
return "3.4"


schema = strawberry.Schema(Query)

str(
schema
) == """
type Query {
a: String!
b: Int!
c: Float!
}
"""


Contributed by [Jonathan Kim](https://github.com/jkimbo) via [PR #2313](https://github.com/strawberry-graphql/strawberry/pull/2313/)

0.150.1

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

Fixed field resolvers with nested generic return types
(e.g. `list`, `Optional`, `Union` etc) raising TypeErrors.
This means resolver factory methods can now be correctly type hinted.

For example the below would previously error unless you ommited all the
type hints on `resolver_factory` and `actual_resolver` functions.
python
from typing import Callable, Optional, Type, TypeVar

import strawberry


strawberry.type
class Cat:
name: str


T = TypeVar("T")


def resolver_factory(type_: Type[T]) -> Callable[[], Optional[T]]:
def actual_resolver() -> Optional[T]:
load rows from database and cast to type etc
...

return actual_resolver


strawberry.type
class Query:
cat: Cat = strawberry.field(resolver_factory(Cat))


schema = strawberry.Schema(query=Query)


Contributed by [Tim OSullivan](https://github.com/invokermain) via [PR #1900](https://github.com/strawberry-graphql/strawberry/pull/1900/)

0.150.0

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

This release implements the ability to use custom caching for dataloaders.
It also allows to provide a `cache_key_fn` to the dataloader. This function
is used to generate the cache key for the dataloader. This is useful when
you want to use a custom hashing function for the cache key.

Contributed by [Aman Choudhary](https://github.com/Techno-Tut) via [PR #2394](https://github.com/strawberry-graphql/strawberry/pull/2394/)

0.149.2

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

This release fixes support for generics in arguments, see the following example:

python
T = TypeVar("T")


strawberry.type
class Node(Generic[T]):
strawberry.field
def data(self, arg: T) -> T: `arg` is also generic
return arg


Contributed by [A. Coady](https://github.com/coady) via [PR #2316](https://github.com/strawberry-graphql/strawberry/pull/2316/)

0.149.1

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

This release improves the performance of rich exceptions on custom scalars
by changing how frames are fetched from the call stack.
Before the change, custom scalars were using a CPU intensive call to the
`inspect` module to fetch frame info which could lead to serious CPU spikes.

Contributed by [Paulo Amaral](https://github.com/paulopaixaoamaral) via [PR #2390](https://github.com/strawberry-graphql/strawberry/pull/2390/)

0.149.0

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

This release does some internal refactoring of the HTTP views, hopefully it
doesn't affect anyone. It mostly changes the status codes returned in case of
errors (e.g. bad JSON, missing queries and so on).

It also improves the testing, and adds an entirely new test suite for the HTTP
views, this means in future we'll be able to keep all the HTTP views in sync
feature-wise.

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

Page 39 of 122

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.