MIT License
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).
Use poetry to install dependencies:
poetry install
poetry run pre-commit install
Run alembic to create the database and populate it with movie data:
poetry run alembic upgrade head
Run uvicorn to run the server:
poetry run uvicorn main:app --reload
The GraphQL API should now be available at http://localhost:8000/graphql
poetry run uvicorn main:app --reload
poetry run strawberry export-schema main:schema
query AllTopRatedMovies {
topRatedMovies {
id
imageUrl
imdbId
imdbRating
imdbRatingCount
title
year
director {
id
name
}
}
}
key | description |
---|---|
eq | equal |
ne | not equal |
like | like |
iLike | insensitive like |
isNull | is null |
in | in |
notIn | not in |
lt | less than |
lte | less than or equal |
gt | greater than |
gte | greater than or equal |
{
allUsers(
filters: {
isActive: true
or: [{ isAdmin: true }, { usernameIn: ["moderator", "cool guy"] }]
}
) {
edges {
node {
id
username
}
}
}
}
{
allUsers(filters: { isActive: true }) {
edges {
node {
id
}
}
}
allGroups {
edges {
node {
users(filters: { isActive: true }) {
edges {
node {
id
}
}
}
}
}
}
}