Exemple GraphQL server based on Koa, Mongoose and Apollo.
Clone the repo:
git clone https://github.com/lilfaf/graphql-backend-poc.git
Install it:
cd graphql-backend-poc
yarn install
Setup mongo databse:
mongo
> use graphql-backend-poc
> db.users.insert({ firstName: 'foo', lastName: 'bar' })
> db.users.find()
> exit
Run it:
yarn run dev
Visit graphiql at http://localhost:3000/graphiql
and try out the following queries
Users list:
{
Users {
_id
firstName
lastName
}
}
Single user:
{
User(id: "your-id-here") {
firstName
lastName
}
}