Create GraphQL Api Service + Realtime PubSub use Golang
- MYSQL (currently use MYSQL database)
- Change database connection in /config/config.go
- Import schema.sql to database
mysql -u root -p YOUR-DATABASE-NAME < schema.sql
go run main.go
var ws = new WebSocket("ws://127.0.0.1:3001/ws");
ws.onmessage = (msg) => {
console.log("received server message:", msg.data)
}
// Subscribe to a topic
ws.send('{"action": "subscribe", "topic": "topic-xyz"}')
// Publish a message
ws.send('{"action": "public", "topic": "topic-xyz", "message": "Your message"}')
