2. Project setup
3m

Overview

Let's meet the project we'll be working with in this series. In this lesson, we will:

  • Examine our API so far and our future plans 🍲🥘
  • Learn what offers to help make app development easier and faster

Our API so far...

Introducing Poetic Plates 🍽️, the GraphQL API for adventurous cooks and foodies!

Poetic Plates API title

Ever find yourself at a loss for what to cook for dinner, endlessly scrolling through videos and websites, and getting hangrier by the minute?

Poetic Plates lets you try your hand at AI-generated recipes with poetic instructions and delicious (or potentially disastrous) results. With extremely detailed and sometimes helpful instructions, cooking has never been more fun!

The API architecture

The Poetic Plates API is written in JavaScript and uses . Here's what the codebase directory looks like:

📦 poetic-plates-api
┣ 📂 src
┃ ┣ 📂 datasources
┃ ┣ 📂 resolvers
┃ ┣ 📄 index.js
┣ 📄 package.json
┣ 📄 schema.graphql
┗ 📄 README.md

If you've built APIs before, this might look familiar! It's a with a schema, and . Here's the quick rundown for the important files:

  • schema.graphql: A schema that defines the types and that describe our recipes content.
  • resolvers: Defines functions for the in the schema.
  • datasources: In a real-world application, this would probably connect to a REST API or a database, but we're in tutorial-land so we're using hard-coded data in a JSON file in the same directory.
  • index.js: Creates an ApolloServer instance that uses the three components above.

You won't need to clone the repository, but feel free to browse the codebase if you're curious.

Poetic Plates is hosted at https://poetic-plates-recipes-api.herokuapp.com/, ready to receive queries and return data!

Wanna try it out? Open up a new terminal and paste this curl command from the homepage. We can tweak the to ask for a random recipe's name.

curl --request POST \
--header 'content-type: application/json' \
--url 'https://poetic-plates-recipes-api.herokuapp.com/' \
--data '{"query":"query GetRandomRecipe {\n randomRecipe {\n name\n readyTime\n servings\n ingredients {\n text\n }\n }\n}"}'

And we get data back: a random recipe with information about how long it takes to cook and the ingredients it needs!

How we're using Poetic Plates

Right now, the API is simply a small collection of recipes. We can do things like:

  • ask it for a random recipe
  • ask it for the full list of recipes in its database
  • ask it for the most recently added recipes
  • see a recipe's ingredients, cooking time, instructions, and more

But we've got big plans for Poetic Plates! We imagine a future where users can add their own recipes, create collections, and share their thoughts. We could provide more details about each ingredient, or recommend specific recipes based on what's already in their pantry. The possibilities are endless!

While we're working on these new features and growing our schema, we also want to keep our current functionality up and running smoothly. We want to track the health of our API, and monitor things like which aren't being used, what are the most requested , or which parts of a are way too slow. What's causing problems for the clients using it? Where can we improve?

Working with GraphOS

helps us solve these problems.

To get started with , we're going to use its web interface, Studio. There are two other ways to connect with : Rover, a command-line interface used locally or in a CI/CD pipeline; and the Platform API, which is a API to perform actions in your own application.

In this course, we'll primarily be working with Studio, so you'll need an account to follow along!

Creating an Apollo account

In case you haven't created your Apollo account yet, visit https://studio.apollographql.com/signup. You can sign up either with an email and password, or with an existing GitHub account. You'll also create your own organization.

After that, you're all set to use .

Task!

Practice

Which of the following are valid ways to interface with GraphOS?

Key takeaways

  • helps you build, manage, and scale your API.
  • There are three ways to interface with : Studio, , and the Platform API.
  • In this tutorial, we'll be working with an existing API called Poetic Plates 🍽️, the GraphQL API for adventurous cooks and foodies!

Up next

All right, we're ready to take Poetic Plates to the next level. is going to transform our API into a federated graph. If you're not familiar with this federated architecture, don't worry! We'll cover it all in the next lesson.

Previous

Share your questions and comments about this lesson

Your feedback helps us improve! If you're stuck or confused, let us know and we'll help you out. All comments are public and must follow the Apollo Code of Conduct. Note that comments that have been resolved or addressed may be removed.

You'll need a GitHub account to post below. Don't have one? Post in our Odyssey forum instead.