Earlier this year, I worked on a project for a large client. Our task was entirely focused on the front end, while the back end was specified and developed by another team. These days, many new projects opt for GraphQL, but we weren’t so lucky; the other team decided to go ahead with a REST […]
This is a quick guide to getting a lightweight GraphQL server via API route in a Next.js app. This is not a detailed tutorial of how to create a beautiful, semantic GraphQL and Next.js toolkit. Where we’re starting: A basic Next.js app with a Postgres database. Where we’re going: A request to an api/graphql endpoint […]
Visual Studio is an excellent integrated development environment (IDE), but sometimes it needs a little hand-holding. Throughout my experience with VS Code, it has never delivered on project-wide type checking and linting. Rather than getting instant feedback from my IDE, I’ve had to rely on my build process as a type checker. Type errors only […]
I recently worked on a story to replace a dynamic, clever use of React’s useContext hook with a technique called props drilling. For some developers, this might seem like a step backward. In our case, however, the combination of props drilling and TypeScript’s safety and editor support allowed for a simpler, more bug-proof development experience.
Much of TypeScript’s flexibility comes from its support for generics. They’re great for building up reusable abstractions so that you can share the “how” across your codebase even as the “what” varies significantly. In this post, I’ll describe a limitation that recently got in my way, and how I worked around it.
When writing tests for a Node.js server, it’s common to test the database as well. (At least, one hopes.) Here are a few helper functions for testing a PostgreSQL database using Knex.
My team and I recently decided that we should store user-generated binary files in our PostgreSQL database so that a user could download them at a later time. This is different from uploading those files to something like Amazon S3 (which we’ll likely consider migrating to at some point down the road).
Most applications with user accounts will need to do permission checking. Of course, it’s important to include all of the appropriate testing to ensure that only users with the correct permissions can perform certain actions. But what if we also had a way to explicitly tell anyone making calls to restricted functions that a particular […]
Both GraphQL and TypeScript support the concept of discriminated unions (also known as tagged unions). In this post, I’ll walk through setting up an example GraphQL schema and the corresponding TypeScript types, along with writing a query to retrieve a union type.