Design APIs Using GraphQL

Making a good API design is a challenging task that rewards iteration, experimentation, and a thorough understanding of the business domain. For this lesson, let’s imagine that we work at a next-generation pizza company. We have an existing GraphQL API for an existing feature for the current business model. We now want to introduce a new feature. On the backend, the new feature requires the following implementations:

  • All pizzas must have essential attributes like pizza and description that indicate which topping or sauce they will be served with.
  • Some types of pizza must have customizable unique attributes. For example, we should be able to customize the sauce in a Neapolitan pizza and the crust in a St. Louis pizza.

With these requirement fulfilled, we can start thinking about the API design we’ll use to introduce the new feature.

Helicopter view

A naive version of the schema based on the listed requirements might look something like this:

Get hands-on with 1200+ tech skills courses.