Skip to content

Latest commit

 

History

History

fastapi-sqlalchemy

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

FastAPI + SQLAlchemy

This examples shows you how to setup Strawberry with FastAPI and SQLAlchemy. It setups a GraphQL API to fetch the top rated movies from IMDB (stored in a sqlite DB).

How to use

  1. Install dependencies

Use poetry to install dependencies:

poetry install
  1. Run migrations

Run alembic to create the database and populate it with movie data:

poetry run alembic upgrade head
  1. Run the server

Run uvicorn to run the server:

poetry run uvicorn main:app --reload

The GraphQL API should now be available at http://localhost:8000/graphql

Example query

query AllTopRatedMovies {
  topRatedMovies {
    id
    imageUrl
    imdbId
    imdbRating
    imdbRatingCount
    title
    year
    director {
      id
      name
    }
  }
}