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.
For the last few years, we’ve been using a universal TypeScript platform including TypeScript, GraphQL, React, and Express. Having TypeScript on both the client and the server (including command-line utilities and background worker processes) has transformed how we go about ensuring the quality of the software we build. When compared to other stacks we’ve used, […]