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).
- Install dependencies
Use poetry to install dependencies:
poetry install
- Run migrations
Run alembic to create the database and populate it with movie data:
poetry run alembic upgrade head
- 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
query AllTopRatedMovies {
topRatedMovies {
id
imageUrl
imdbId
imdbRating
imdbRatingCount
title
year
director {
id
name
}
}
}