A GraphQL library for Python that leverages type annotations 🍓
MIT License
Published by botberry almost 4 years ago
Bugfix to allow the use of UNSET
as a default value for arguments.
import strawberry
from strawberry.arguments import UNSET, is_unset
@strawberry.type
class Query:
@strawberry.field
def hello(self, name: Optional[str] = UNSET) -> str:
if is_unset(name):
return "Hi there"
return "Hi {name}"
schema = strawberry.Schema(query=Query)
result = schema.execute_async("{ hello }")
assert result.data == {"hello": "Hi there"}
result = schema.execute_async('{ hello(name: "Patrick" }')
assert result.data == {"hello": "Hi Patrick"}
SDL:
type Query {
hello(name: String): String!
}
Published by botberry almost 4 years ago
This release improves mypy support for strawberry.field
Published by botberry almost 4 years ago
FieldDefinition
object ontoStrawberryResolver
object with the useful properties.arguments.get_arguments_from_resolver
is now theStrawberryResolver.arguments
propertydataclasses.field
but not annotated. This was previouslyPublished by botberry almost 4 years ago
This release fixes an issue with forward types
Published by botberry almost 4 years ago
This release adds a built-in dataloader. Example:
async def app():
async def idx(keys):
return keys
loader = DataLoader(load_fn=idx)
[value_a, value_b, value_c] = await asyncio.gather(
loader.load(1),
loader.load(2),
loader.load(3),
)
assert value_a == 1
assert value_b == 2
assert value_c == 3
Published by botberry almost 4 years ago
Allow interfaces to implement other interfaces.
This may be useful if you are using the relay pattern
or if you want to model base interfaces that can be extended.
Example:
import strawberry
@strawberry.interface
class Error:
message: str
@strawberry.interface
class FieldError(Error):
message: str
field: str
@strawberry.type
class PasswordTooShort(FieldError):
message: str
field: str
fix: str
Produces the following SDL:
interface Error {
message: String!
}
interface FieldError implements Error {
message: String!
field: String!
}
type PasswordTooShort implements FieldError & Error {
message: String!
field: String!
fix: String!
}
Published by botberry almost 4 years ago
Fix mypy plugin to handle bug where the types
argument to strawberry.union
is passed in as a keyword argument instead of a position one.
MyUnion = strawberry.union(types=(TypeA, TypeB), name="MyUnion")
Published by botberry almost 4 years ago
This release adds a new AsyncGraphQLView for django.
Published by botberry almost 4 years ago
Improve typing for field
and StrawberryField
.
Published by botberry almost 4 years ago
This release disable implicit re-export of modules. This fixes Strawberry for you if you were using implicit_reexport = False
in your MyPy config.
Published by botberry almost 4 years ago
This fixes the prettier pre-lint check.
Published by botberry almost 4 years ago
Fix issue when using strawberry.enum(module.EnumClass)
in mypy
Published by botberry almost 4 years ago
This release adds support to mark a field as deprecated via deprecation_reason
Published by botberry almost 4 years ago
Set default value to null in the schema when it's set to None
Published by botberry almost 4 years ago
Register UUID's as a custom scalar type instead of the ID type.
⚠️ This is a potential breaking change because inputs of type UUID are now parsed as instances of uuid.UUID instead of strings as they were before.
Published by botberry almost 4 years ago
This release fixes a bug when returning list in async resolvers
Published by botberry almost 4 years ago
This release improves how we check for enums
Published by botberry almost 4 years ago
This release improves how we handle enum values when returing lists of enums.
Published by botberry about 4 years ago
This releases adds a workaround to prevent mypy from crashing in specific occasions
Published by botberry about 4 years ago
This release fixes an issue preventing to return enums in lists