📜

Open-source updates
30 August 2021

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!

# PR reviews

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.

PR here: https://github.com/strawberry-graphql/strawberry/pull/1162

Jon also made a PR to lazily access properties in the info object, this was a performance regression from when we introduced our custom Info type.

PR here: https://github.com/strawberry-graphql/strawberry/pull/1165

As a followup to Jon's PR A. Coady made a PR to cache the selected_field property so that multiple access won't recalculate it.

PR here: https://github.com/strawberry-graphql/strawberry/pull/1167

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
@strawberry.mutation
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!

PR here: https://github.com/strawberry-graphql/strawberry/pull/1168

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!

PR here: https://github.com/strawberry-graphql/strawberry/pull/1169

# Bug fixes

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).

PRs:

https://github.com/strawberry-graphql/strawberry/pull/1170 https://github.com/strawberry-graphql/strawberry/pull/1171

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 type of 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):
...

PR here: https://github.com/strawberry-graphql/strawberry/pull/1175

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 for strawberry.field but alas this won't happen as the solution for adding typing support is tied to the dataclasses semantic and strawberry.field don't match one to one to dataclasses.

PR here: https://github.com/strawberry-graphql/strawberry/pull/922

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.

PR here: https://github.com/strawberry-graphql/strawberry/pull/1179

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 :)

PR here: https://github.com/strawberry-graphql/strawberry/pull/1181

# Apollo Federation

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

# Fin

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 🇮🇹

Webmentions

No replies found! Tweet about this post, and it will show up here! ☝