Simple application used to demonstrate minimalistic setup for an Apollo GraphQL Subscriptions architecture.
.---------. .--------.
| Client |-. GET / | Web |
| Browser | | -----------------------> | Server |
'---------' | '--------'
'---------'
|
| .---------.
| GET /graphiql | GraphQL |
'-----------------------------> | Server |
Websocket '---------'
- Browser starts by connecting to Web App and fetch available messages
- Web page opens websocket tunnel to GraphQL server and subscribes to new messages
- GraphQL mutations can then be submitted to the GraphQL server and new messages submitted to websocket clients for browser update
In a terminal do:
cd server-app
yarn start
In another terminal
cd client-app
yarn start
- Open a browser window with the client page
- Open another browser window with GraphiQL and press ►
Your client page should now be displaying the new message.
Using CURL to exercise GraphQL Mutation:
curl -k -H "Content-Type: application/json" -X POST -d '{ "operationName": null, "query": "mutation { addMessage(message: \"My CURL message\") }", "variables": "{}" }' http://localhost:5060/graphql
For an example using the withApollo decorator see the withApollo branch.
Checkout subscribeToMore branch for an example implementation using Apollo's subscribeToMore subscription callback function.