Strawberry-graphql

Latest version: v0.229.1

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

Scan your dependencies

Page 35 of 119

0.155.0

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

This release adds a new utility function to convert a Strawberry object to a
dictionary.

You can use `strawberry.asdict(...)` function to convert a Strawberry object to
a dictionary:

python
strawberry.type
class User:
name: str
age: int


should be {"name": "Lorem", "age": 25}
user_dict = strawberry.asdict(User(name="Lorem", age=25))


> Note: This function uses the `dataclasses.asdict` function under the hood, so
> you can safely replace `dataclasses.asdict` with `strawberry.asdict` in your
> code. This will make it easier to update your code to newer versions of
> Strawberry if we decide to change the implementation.

Contributed by [Haze Lee](https://github.com/Hazealign) via [PR #2417](https://github.com/strawberry-graphql/strawberry/pull/2417/)

0.154.1

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

Fix `DuplicatedTypeName` exception being raised on generics declared using
`strawberry.lazy`. Previously the following would raise:

python
issue_2397.py
from typing import Annotated, Generic, TypeVar

import strawberry

T = TypeVar("T")


strawberry.type
class Item:
name: str


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


strawberry.type
class Query:
edges_normal: Edge[Item]
edges_lazy: Edge[Annotated["Item", strawberry.lazy("issue_2397")]]


if __name__ == "__main__":
schema = strawberry.Schema(query=Query)


Contributed by [pre-commit-ci](https://github.com/pre-commit-ci) via [PR #2462](https://github.com/strawberry-graphql/strawberry/pull/2462/)

0.154.0

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

Support constrained float field types in Pydantic models.

i.e.

python
import pydantic


class Model(pydantic.BaseModel):
field: pydantic.confloat(le=100.0)
equivalent_field: float = pydantic.Field(le=100.0)


Contributed by [Etienne Wodey](https://github.com/airwoodix) via [PR #2455](https://github.com/strawberry-graphql/strawberry/pull/2455/)

0.153.0

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

This change allows clients to define connectionParams when making Subscription requests similar to the way [Apollo-Server](https://www.apollographql.com/docs/apollo-server/data/subscriptions/#operation-context) does it.

With [Apollo-Client (React)](https://www.apollographql.com/docs/react/data/subscriptions/#5-authenticate-over-websocket-optional) as an example, define a Websocket Link:

import { GraphQLWsLink } from 'apollo/client/link/subscriptions';
import { createClient } from 'graphql-ws';

const wsLink = new GraphQLWsLink(createClient({
url: 'ws://localhost:4000/subscriptions',
connectionParams: {
authToken: user.authToken,
},
}));

and the JSON passed to `connectionParams` here will appear within Strawberry's context as the `connection_params` attribute when accessing `info.context` within a Subscription resolver.

Contributed by [Tommy Smith](https://github.com/tsmith023) via [PR #2380](https://github.com/strawberry-graphql/strawberry/pull/2380/)

0.152.0

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

This release adds support for updating (or adding) the query document inside an
extension's `on_request_start` method.

This can be useful for implementing persisted queries. The old behavior of
returning a 400 error if no query is present in the request is still supported.

Example usage:

python
from strawberry.extensions import Extension


def get_doc_id(request) -> str:
"""Implement this to get the document ID using your framework's request object"""
...


def load_persisted_query(doc_id: str) -> str:
"""Implement this load a query by document ID. For example, from a database."""
...


class PersistedQuery(Extension):
def on_request_start(self):
request = self.execution_context.context.request

doc_id = get_doc_id(request)

self.execution_context.query = load_persisted_query(doc_id)


Contributed by [James Thorniley](https://github.com/jthorniley) via [PR #2431](https://github.com/strawberry-graphql/strawberry/pull/2431/)

0.151.3

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

Page 35 of 119

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.