Last two weeks have been a bit hectic personally, that's why I'm only posting my weekly update now. Highlights from the last week are: a new FastAPI integration, an update to our Pydantic integration, a
merge_types utility and improvements to our tests.
# FastAPI integration
We used to recommend using ASGI for integrating for FastAPI, but now we have a better integration based on API Routers and allows to use FastAPI's dependency injection system.
Also super happy to see many people reviewing this PR and making it better 😊
# Pydantic integration update
Matt Allen made a PR to udpdate our Pydantic integration to match Strawberry's Django API. The old API is now deprecated, but we will keep it for a while since it is being used by few people. The API looks like this:
import pydanticimport strawberryfrom strawberry.experimental.pydantic import autoclass User(pydantic.BaseModel):age: intpassword: email@example.com(User)class UserType:age: autopassword: auto
instead of passing a list of
fields to the decorator, you can now use the same
API you use for all our decorators, but you can also use the "magic"
keyword to let Strawberry infer the type from the Pydantic model.
This API is much nice than
fields since it allows to easily declared the
exposed fields and allows to also edit description of a specific field without
having to pass the type of the field manually.
@strawberry.typeclass QueryA:...@strawberry.typeclass QueryB:...ComboQuery = merge_types((QueryB, QueryA))schema = strawberry.Schema(query=ComboQuery)
This is an alternative to create a class that inherits from both
QueryB, and might be preferred by some people.
# Test improvements
Now that we have tests running on windows, I've made a PR to add caching to our tests. Not sure I didn't do this earlier, but now our tests should run quite faster as they don't install all the dependencies all the time.
I've also made a PR to separate the Django tests. So now we have less tests to run for each python version and we'll also only run Django tests for the latest version of Django. There's not much need for us to run Django tests for multiple python versions. This will make our test suite faster.
# Other PRs
Ester made a
PR to add some checks when using
@strawberry.type and other decorators.
This will make it easier to work with Strawberry as it should make it easier to
identify potential mistakes.
Finally Jon made a PR to update our schema docs
I made a PR to run tests on Python 3.10 stable.
I also had to make a fix to prevent Strawberry to install FastAPI by default. Turns out marking dependencies as optional doesn't work if they are not in an "extra" group.
I'm falling a bit behind with these updates, as they were supposed to be weekly updates, but in the last months I skipped them twice. I'll try to get back on track soon, I have some personal life changes happening now, but hopefully they won't distract me too much 😊
No replies found! Tweet about this post, and it will show up here! ☝