Releases: strawberry-graphql/strawberry
🍓 0.270.4
🍓 0.270.3
🍓 0.270.2
🍓 0.270.1
🍓 0.270.0
🍓 0.269.0
🍓 0.268.2
🍓 0.268.1
This releases fixed an issue that prevented from using ID and GlobalID at the same
time, like in this example:
import strawberry
from strawberry.relay.types import GlobalID
@strawberry.type
class Query:
@strawberry.field
def hello(self, id: GlobalID) -> str:
return "Hello World"
@strawberry.field
def hello2(self, id: strawberry.ID) -> str:
return "Hello World"
schema = strawberry.Schema(
Query,
)Releases contributed by @patrick91 via #3855
🍓 0.268.0
This release renames the generated type from GlobalID to ID in the GraphQL
schema.
This means that when using relay.Node, like in this example:
@strawberry.type
class Fruit(relay.Node):
code: relay.NodeID[int]
name: strYou'd create a GraphQL type that looks like this:
type Fruit implements Node {
id: ID!
name: String!
}while previously you'd get this:
type Fruit implements Node {
id: GlobalID!
name: String!
}The runtime behaviour is still the same, so if you want to use GlobalID in
Python code, you can still do so, for example:
@strawberry.type
class Mutation:
@strawberry.mutation
@staticmethod
async def update_fruit_weight(id: relay.GlobalID, weight: float) -> Fruit:
# while `id` is a GraphQL `ID` type, here is still an instance of `relay.GlobalID`
fruit = await id.resolve_node(info, ensure_type=Fruit)
fruit.weight = weight
return fruitIf you want to revert this change, and keep GlobalID in the schema, you can
use the following configuration:
schema = strawberry.Schema(
query=Query, config=StrawberryConfig(relay_use_legacy_global_id=True)
)Releases contributed by @patrick91 via #3853
🍓 0.267.0
This release adds support to use strawberry.Parent with future annotations.
For example, the following code will now work as intended:
from __future__ import annotations
def get_full_name(user: strawberry.Parent[User]) -> str:
return f"{user.first_name} {user.last_name}"
@strawberry.type
class User:
first_name: str
last_name: str
full_name: str = strawberry.field(resolver=get_full_name)
@strawberry.type
class Query:
@strawberry.field
def user(self) -> User:
return User(first_name="John", last_name="Doe")
schema = strawberry.Schema(query=Query)Or even when not using future annotations, but delaying the evaluation of User, like:
# Note the User being delayed by passing it as a string
def get_full_name(user: strawberry.Parent["User"]) -> str:
return f"{user.first_name} {user.last_name}"
@strawberry.type
class User:
first_name: str
last_name: str
full_name: str = strawberry.field(resolver=get_full_name)
@strawberry.type
class Query:
@strawberry.field
def user(self) -> User:
return User(first_name="John", last_name="Doe")
schema = strawberry.Schema(query=Query)Releases contributed by @bellini666 via #3851