Apollo Server 2 how to setup subscriptions
This project is a good starting point for all the people that want to have apollo-server 2.0 ready to use. It integrates:
error.log
and write on it in case of error - to change the level edit common/util/logger.ts
lines 12, 13, 14 )install mongodb - refer to mongodb guide
npm install
In the root folder is available a file called .env
. It contains all the configuration environment for:
npm run dev
(it will automatically rerun your code all the time you save and will check for tslint errors and formatting style errors.)npm run prod
prettier-vscode can be installed using the extension sidebar. Search for Prettier - Code formatter. It can also be installed using ext install prettier-vscode in the command palette.
https://prettier.io/docs/en/editors.html
query {
hello
}
query {
posts {
author
comment
}
}
mutation {
addPost(author: "Daniele Zurico", comment: "www.dzurico.com") {
author
comment
}
}
subscription {
postAdded {
author
comment
}
}
query{
users {
id
name
surname
}
}
For a better explanation on how I setup this repo please refer to: