This repository holds a Graphql example using Graphene and Mongoengine.
- Docker
- Docker compose
docker compose up
This will start the server on http://localhost:8000/
. By default the database is empty, but you can add some fake data by running the following command:
docker compose exec graphene python -m database.seed --users 10 --posts 10 --comments 10
This will create 10 users, 10 posts generated by any random user in the database, and 10 comments on any random post in the database. You can of course change the number of each entity.
You can use the GraphiQL interface to query the server. You can access it by going to http://localhost:8000/
. A simple query would be:
{
users {
id
name
email
}
}
Or you can filter the users by username
:
{
users(username: "John") {
id
name
email
}
}
Filtering can be done on any field defined as argument in each property of my_graphql.query.Query
.