Open-source updates - 30 August 2021
Published by Patrick Arminio on
This week I've spent time on reviewing PRs, fixing some small bugs and writing docs. Oh and we finally have docs for Apollo Federation!
Jon sent a PR to change the pinned version of GraphQL-core. We need this because GraphQL-core doesn’t really follow semantic versioning, so minor changes could include breaking changes.
Jon also made a PR to lazily access properties in
info object, this was a performance regression from when we introduced our
As a followup to Jon’s PR A. Coady made a PR to
selected_field property so that multiple access won’t recalculate
Joe Freeman sent a very interesting PR to add support for background tasks in the ASGI implementation. Now you can start background tasks by doing something like this:
from starlette.background import BackgroundTask
def create_flavour(self, info: Info) -> str:
info.context["response"].background = BackgroundTask(...)
This is a pretty cool feature of Starlette that I didn’t about!
Joe also sent a PR to add support for opentelemetry 1.0. This is something we should have done a while ago, so I’m glad Joe spent a bit of time on it!
I’ve also made two PRs related to opentelemetry. One to fix a small issue with the version number for opentelemetry and one to fix an import error that was happening when you didn’t have opentelemetry installed (since it is an optional dependency).
I’ve also made a PR to improve mypy support for
create_type as mypy doesn’t
yet support creating new types from functions. Our plugin now changes the return
create_type to be a
TypeAlias and now you can do this without
getting an error:
import strawberry from strawberry.tools import create_type @strawberry.field def name() -> str: return "foo" MyType = create_type("MyType", [name]) class Query(MyType): ...
Speaking of mypy, I’ve gotten back to the PR to add support to PyRight, but I
haven’t yet finished it as there’s a couple of things I want to improve first.
Also I’ve asked the maintainer of PyRight to see if we could get some support
strawberry.field but alas this won’t happen as the solution for adding
typing support is tied to the dataclasses semantic and
match one to one to dataclasses.
I’ve made a PR to add support for async directives. This also fixed a bug when using directives and async extensions. I think we should make sure async works for all the use cases as it will probably become more important in the future.
I’ve also made a PR to accept click 8.0 as a dependency. I think this was asked on Discord a while ago, so it was about time to fix it :)
We also merged the PR that I made to add a guide on how to use Apollo Federation with Strawberry. I did open this PR one year ago 😮 and I’m glad I finally made time to finish it as people have requested it.
I’ve also made a companion repository for the docs, available here: https://github.com/strawberry-graphql/federation-demo
I think this was a good week! I still have a lot of PR to review, but the number of open PRs seems to be going down over time. Also thanks to Jon and Bryce for reviewing and merging PRs over time ♥️
Written somewhere near Venice 🇮🇹