EXAMPLE OF NODE.JS USING:
- GRAPHQL SUBSCRIPTIONS: LIKE QUERIES, SUBSCRIPTIONS ENABLE YOU TO FETCH DATA. UNLIKE QUERIES, SUBSCRIPTIONS ARE LONG-LASTING OPERATIONS THAT CAN CHANGE THEIR RESULT OVER TIME. THEY CAN MAINTAIN AN ACIVE CONNECTION TO YOUR GRAPHQL SERVER (MOST COMMONLY VIA WEBSOCKET), ENABLING THE SERVER TO PUSH UPDATES TO THE SUBSCRIPTION'S RESULT. SUBSCRIPTIONS ARE USEFUL FOR NOTIFYING YOUR CLIENT IN REAL TIMA ABOUT CHANGES TO BACK-END DATA, SUCH AS CREATION OF NEW OBJECT OR UPDATES TO AN IMPORTANT FIELD.
- ALTAIR GRAPHQL CLIENT: A GRAPHICAL, INTERACTIVE AND IN-BROWSER GRAPHQL IDE.
- NODEMON: FOLLOW THE INSTRUCTIONS HERE.
- EXPRESS: FOLLOW THE INSTRUCTIONS HERE.
- TYPESCRIPT: FOLLOW THE INSTRUCTIONS HERE.
- GRAPHQL MODULES: FOLLOW THE INSTRUCTIONS HERE.
- FOR SUBSCRIPTIONS:
npm install ws
npm install -D @types/ws # ONLY IF WORKING WITH TYPESCRIPT
npm install graphql-ws
npm install graphql-subscriptions
- FOR ALTAIR GRAPHQL CLIENT:
npm install altair-static
npm run tsc-nodemon --jsfile=./folderDist/folderTopics/folderGraphqlSubscriptions/exampleGraphqlSubscriptions.js