Strawberry-graphql

Latest version: v0.229.1

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

Scan your dependencies

Page 61 of 119

0.98.2

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

Adds support for converting pydantic conlist.
Note that constraint is not enforced in the graphql type.
Thus, we recommend always working on the pydantic type such that the validation is enforced.

python
import strawberry
from pydantic import BaseModel, conlist


class Example(BaseModel):
friends: conlist(str, min_items=1)


strawberry.experimental.pydantic.input(model=Example, all_fields=True)
class ExampleGQL: ...


strawberry.type
class Query:
strawberry.field()
def test(self, example: ExampleGQL) -> None:
friends may be an empty list here
print(example.friends)
calling to_pydantic() runs the validation and raises
an error if friends is empty
print(example.to_pydantic().friends)


schema = strawberry.Schema(query=Query)


The converted graphql type is

input ExampleGQL {
friends: [String!]!
}


Contributed by [James Chua](https://github.com/thejaminator) [PR #1656](https://github.com/strawberry-graphql/strawberry/pull/1656/)

0.98.1

-------------------

This release wasn't published on PyPI

0.98.0

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

0.97.0

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

Support "void" functions

It is now possible to have a resolver that returns "None". Strawberry will automatically assign the new `Void` scalar in the schema
and will always send `null` in the response

Exampe

python
strawberry.type
class Mutation:
strawberry.field
def do_something(self, arg: int) -> None:
return

results in this schema:
grapqhl
type Mutation {
doSomething(arg: Int!): Void
}


Contributed by [Paulo Costa](https://github.com/paulo-raca) [PR #1648](https://github.com/strawberry-graphql/strawberry/pull/1648/)

0.96.0

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

Add better support for custom Pydantic conversion logic and standardize the
behavior when not using `strawberry.auto` as the type.

See https://strawberry.rocks/docs/integrations/pydantic#custom-conversion-logic for details and examples.

Note that this release fixes a bug related to Pydantic aliases in schema
generation. If you have a field with the same name as an aliased Pydantic field
but with a different type than `strawberry.auto`, the generated field will now
use the alias name. This may cause schema changes on upgrade in these cases, so
care should be taken. The alias behavior can be disabled by setting the
`use_pydantic_alias` option of the decorator to false.

Contributed by [Matt Allen](https://github.com/Matt343) [PR #1629](https://github.com/strawberry-graphql/strawberry/pull/1629/)

0.95.5

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

Adds support for `use_pydantic_alias` parameter in pydantic model conversion.
Decides if the all the GraphQL field names for the generated type should use the alias name or not.

python
from pydantic import BaseModel, Field
import strawberry


class UserModel(BaseModel):
id: int = Field(..., alias="my_alias_name")


strawberry.experimental.pydantic.type(UserModel, use_pydantic_alias=False)
class User:
id: strawberry.auto


If `use_pydantic_alias` is `False`, the GraphQL type User will use `id` for the name of the `id` field coming from the Pydantic model.

type User {
id: Int!
}


With `use_pydantic_alias` set to `True` (the default behaviour) the GraphQL type user will use `myAliasName` for the `id` field coming from the Pydantic models (since the field has a `alias` specified`)

type User {
myAliasName: Int!
}


`use_pydantic_alias` is set to `True` for backwards compatibility.

Contributed by [James Chua](https://github.com/thejaminator) [PR #1546](https://github.com/strawberry-graphql/strawberry/pull/1546/)

Page 61 of 119

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.