FastAPI: Task got Future attached to a different loop

This error is caused by creating an asyncio synchronization primitive such as an asyncio.Event before starting your asyncio loop, then using that primitive in the loop. To fix this, create the primitives you need to use from within the loop. This error was discovered when creating our real-time chat app example. In order to make … Read more

URQL: No exchange has handled operations of kind “subscription”

This error happens when you try to use subscriptions in your URQL app but don’t have a subscription exchange. Fix this by installing subscriptions-transport-ws and adding the subscriptionExchange to your URQL config. This error was discovered when writing the real-time chat app example. If you haven’t already, you should check it out. Let’s look at … Read more

Strawberry: Type Query must define one or more fields

This error occurs when you pass a Strawberry type to strawberry.Schema as the query parameter, but that type doesn’t define any fields. To fix this, define at least one field on the type you passed as the query argument. I came across this error when working on the real-time chat app GraphQL example. Since I … Read more

GraphQL Example: Real-time Chat App Using Subscriptions

The code for this example can be found on GitHub here: This project builds off our previous full-stack GraphQL example. If you’re new to GraphQL and haven’t read it yet, you should check it out. What we’re making We’re going to make a real-time chat application using GraphQL subscriptions. GraphQL subscriptions are implemented with … Read more

FastAPI: Access to fetch blocked by CORS policy

When using FastAPI, this error can occur when your frontend content is being served from a different server (or port) than your backend server. To fix this, import CorsMiddleware from starlette.middleware.cors and add it to your app. What is CORS? CORS stands for “Cross-Origin Request Sharing”. It’s what allows scripts in your browser to safely … Read more

Full Stack GraphQL Example: FastAPI, Strawberry, and URQL

The source code for this article is available on GitHub: This example will walk you through creating a docker compose based full-stack GraphQL API using FastAPI+Strawberry on the backend, and React+URQL on the frontend. The associated GitHub repo is a template and is designed to be used as a starting point for new GraphQL … Read more

Docker: failed to solve with frontend dockerfile.v0

This error is caused by docker-compose not being able to find a Dockerfile in your build context. Fix it by making sure your Dockerfile exists in that directory, and that there’s no typo in the name. It has to be named exactly “Dockerfile”. I came across this error when while working on a guide to … Read more

How to install the latest version of Docker on Ubuntu

You can install the latest version of Docker on Ubuntu with the following command: This will run the script described below, which is also hosted as a gist on GitHub. Why not use apt? The apt repository does not contain the latest version of Docker. As of this writing, the latest version of Docker is … Read more