This is an exercise for implementing GraphQL subscriptions manually with Apollo Server 2, Postgres and NodeJS. It is a basic message stream with channels.
Note: this is not production grade, it is intended to be a simple exercise
- Apollo Server 2.
- Subscriptions.
- Docker.
- Postgres.
- Docker compose.
- Clone the repository.
- Mount the containers
cd server && docker-composer up -d
- Navigate to the GraphQL Playground http://localhost:4000
- The following GraphQL operations are available:
# Gets all the messages for a channel
query Board {
board(channel: "natgeo") {
id
text
}
}
# Subscribes to a channel
subscription Stream {
stream(channel: "natgeo") {
text
}
}
# Posts a message to a channel
mutation Post {
post(channel: "natgeo", text: "hola!") {
text
}
}
- When you are finished, unmount the containers
docker-compose down
- Basic subscriptions server.
- Postgres docker container.
- Database initialization.
- Implement API.
- Update GraphQL Schema.
- Dockerize App.
- Implement graphql-postgres-subscriptions.