1. Overview and setup
5m

Welcome to the start of your GraphQL journey!

What is ? GraphQL is the developer-friendly language for the modern web. It transforms how apps fetch data from an API, enabling you to get exactly what you need with a single query.

With a strongly typed schema at its core, helps you define relationships between data across any number of systems, empowering you to focus on what your data can do instead of where it's stored.

Throughout this course, we're going to learn how fits into our existing architecture and how it works with existing REST APIs and other . We'll learn how to use queries, , , the schema, and in our GraphQL API.

A diagram showing GraphQL as the contact point between multiple clients and the complex architecture of a modern backend

We'll build a using Strawberry, a Python library for building APIs using type annotations.

In this lesson, we will:

  • Learn about what we're building
  • Set up our project environment

Pre-requisites

This course uses Python and Strawberry. You should be familiar with Python and have it installed on your machine. We recommend using the latest version of Python.

We also recommend being familiar with the basics of how to use REST APIs and HTTP requests.

What we're building

Listen up! Ready to tune in to what we're building in this course? Drumroll please 🥁

If you couldn't tell from all those music-related cues, we're building a music catalog API called MusicMatcher that helps us find the right soundtrack for the right moment.

Mockup of MusicMatcher

For this first iteration of MusicMatcher, we'll focus on playlists: showcasing featured playlists, listing a playlist's tracks, and adding tracks. In future courses, we'll add more features like pagination, authentication, intermediate schema design concepts, and federation.

Project setup

To follow along with the course, you will need the following:

Code editor or IDE

We'll be using VS Code but you can feel free to use your favorite editor or IDE for Python development!

Install Python

We're using Python 3.12 in this course. While Strawberry works with Python 3.8+, we recommend using the latest version of Python for the best experience. Find your download link here.

Clone the repo locally

The project repo is a minimal template running Strawberry and FastAPI. It also contains some extra instructions in the README on how to get up and running.

git clone https://github.com/apollographql-education/odyssey-intro-strawberry

Here's what the project looks like:

📦 odyssey-intro-strawberry
┣ 📂 api
┃ ┣ 📂 types
┃ ┃ ┗ 📄 __init__.py
┃ ┗ 📄 __init__.py
┣ 📂 data
┃ ┗ 📄 openapi.json
┣ 📄 main.py
┣ 📄 pyproject.toml
┣ 📄 README.md
┣ 📄 requirements-dev.txt
┗ 📄 requirements.txt

Before installing the dependencies, let's set up a virtual environment to keep our project dependencies isolated from other projects.

python -m venv .venv

This command creates a .venv directory in your project folder. To activate the virtual environment, run:

source .venv/bin/activate
.venv\Scripts\activate

Install dependencies and run the server

Run the following command to install dependencies.

pip install -r requirements.txt -r requirements-dev.txt

Finally, let's run the project.

uvicorn main:app --reload

Note: uvicorn is an ASGI server implementation, using uvloop and httptools. You can learn more about it here.

In the terminal, you should see the output logs:

INFO: Will watch for changes in these directories: ['/🐍/odyssey-intro-strawberry']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [54074] using StatReload
INFO: Started server process [54092]
INFO: Waiting for application startup.
INFO: Application startup complete.

The project will be running on http://localhost:8000.

Task!

FastAPI and Strawberry

In this course, we'll be using FastAPI, but Strawberry supports many other Python web frameworks, including Django, Flask, and more.

Key takeaways

  • enables precise data retrieval with a single , eliminating the need to navigate multiple REST endpoints on the client app side.
  • Strawberry is a Python library for building APIs using type annotations.

Up next

Let's dive into all things . In the next lesson, we'll get into the details of how GraphQL fits into our existing architecture and what exactly makes up a .

Next

Share your questions and comments about this lesson

This course is currently in

beta
. 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.