[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"academy-blogs-en-1-1-all-graphql-websocket-go-real-time-api-all--*":3,"academy-blog-translations-lar2cqpq5juncim":104},{"data":4,"page":92,"perPage":92,"totalItems":92,"totalPages":92},[5],{"alt":6,"collectionId":7,"collectionName":8,"content":9,"cover_image":10,"cover_image_path":11,"created":12,"created_by":13,"expand":14,"id":98,"keywords":99,"locale":74,"published_at":100,"scheduled_at":13,"school_blog":96,"short_description":101,"slug":102,"status":94,"title":6,"updated":103,"updated_by":13,"views":97},"EP.33 Using GraphQL with WebSocket in Go to Build Real-Time APIs","sclblg987654321","school_blog_translations","\u003Ch2>GraphQL and WebSocket – Why Use Them Together?\u003C\u002Fh2>\u003Cp>GraphQL is an API Query Language that allows clients to retrieve only the data they need. WebSocket is a protocol that enables Full-Duplex or Real-Time communication. When combined, we can create APIs that support real-time data updates using GraphQL Subscriptions.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>Using GraphQL Subscriptions with WebSocket\u003C\u002Fh3>\u003Cp>GraphQL Subscriptions allow clients to \"subscribe\" to data changes, and the server will automatically push updates to the client when the data changes.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch4>Example GraphQL Subscription:\u003C\u002Fh4>\u003Cpre>\u003Ccode class=\"language-plaintext\">subscription {\n  newMessage {\n    id\n    content\n    sender\n  }\n}\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>When a new message (newMessage) is added, the server sends the updated data to the client in real-time.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch3>Example Code for Using WebSocket with GraphQL in Go\u003C\u002Fh3>\u003Ch4>1. Installing Required Libraries\u003C\u002Fh4>\u003Cpre>\u003Ccode class=\"language-plaintext\">go get github.com\u002F99designs\u002Fgqlgen\ngo get github.com\u002Fgorilla\u002Fwebsocket\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch4>2. Creating GraphQL Schema\u003C\u002Fh4>\u003Cp>File: schema.graphql\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext\">type Query {\n  messages: [Message!]!\n}\n\ntype Subscription {\n  messageAdded: Message!\n}\n\ntype Message {\n  id: ID!\n  content: String!\n  sender: String!\n}\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch4>3. Implementing GraphQL Resolver\u003C\u002Fh4>\u003Cp>File: resolver.go\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext\">package main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"sync\"\n)\n\ntype Message struct {\n    ID      string\n    Content string\n    Sender  string\n}\n\ntype Resolver struct {\n    mu          sync.Mutex\n    messages    []Message\n    subscribers map[string]chan Message\n}\n\nfunc NewResolver() *Resolver {\n    return &amp;Resolver{\n        messages:    []Message{},\n        subscribers: make(map[string]chan Message),\n    }\n}\n\nfunc (r *Resolver) Subscription_messageAdded(ctx context.Context) (&lt;-chan Message, error) {\n    id := fmt.Sprintf(\"%d\", len(r.subscribers))\n    r.mu.Lock()\n    ch := make(chan Message)\n    r.subscribers[id] = ch\n    r.mu.Unlock()\n\n    go func() {\n        &lt;-ctx.Done()\n        r.mu.Lock()\n        delete(r.subscribers, id)\n        close(ch)\n        r.mu.Unlock()\n    }()\n    return ch, nil\n}\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch4>Challenge!\u003C\u002Fh4>\u003Cp>Try building a real-time notification system using GraphQL Subscriptions and WebSocket to notify users when new messages arrive!\u003C\u002Fp>\u003Chr>\u003Ch4>Next Episode\u003C\u002Fh4>\u003Cp>In EP.34, we will explore how to create a fully functional chat system using GraphQL and WebSocket to support real-time communication! Stay tuned 🚀\u003C\u002Fp>","38_11zon_hb2gpplm72.webp","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclblg987654321\u002F2q3wqkpq42ehz3a\u002F38_11zon_hb2gpplm72.webp","2026-03-04 08:51:21.501Z","",{"keywords":15,"locale":68,"school_blog":78},[16,23,28,33,38,43,48,53,58,63],{"collectionId":17,"collectionName":18,"created":19,"created_by":13,"id":20,"name":21,"updated":22,"updated_by":13},"sclkey987654321","school_keywords","2026-03-04 08:51:14.205Z","laiwsvubam25wcf","GraphQL","2026-04-10 16:14:34.380Z",{"collectionId":17,"collectionName":18,"created":24,"created_by":13,"id":25,"name":26,"updated":27,"updated_by":13},"2026-03-04 08:34:00.920Z","ecac9y661or1xka","WebSocket","2026-04-10 16:08:05.227Z",{"collectionId":17,"collectionName":18,"created":29,"created_by":13,"id":30,"name":31,"updated":32,"updated_by":13},"2026-03-04 08:20:11.547Z","ey3puyme01a9bsw","Go","2026-04-10 16:07:25.893Z",{"collectionId":17,"collectionName":18,"created":34,"created_by":13,"id":35,"name":36,"updated":37,"updated_by":13},"2026-03-04 08:20:14.253Z","ah6lvy4x8qe08l5","Golang","2026-04-10 16:07:26.172Z",{"collectionId":17,"collectionName":18,"created":39,"created_by":13,"id":40,"name":41,"updated":42,"updated_by":13},"2026-03-04 08:46:53.342Z","5ac1xgod1ehyqva","GraphQL Subscriptions","2026-04-10 16:13:20.256Z",{"collectionId":17,"collectionName":18,"created":44,"created_by":13,"id":45,"name":46,"updated":47,"updated_by":13},"2026-03-04 08:51:09.083Z","qnfn648h0o2s90l","Real-Time API","2026-04-10 16:14:33.342Z",{"collectionId":17,"collectionName":18,"created":49,"created_by":13,"id":50,"name":51,"updated":52,"updated_by":13},"2026-03-04 08:51:13.649Z","wcctbc65iq5n4bj","GraphQL API","2026-04-10 16:14:34.086Z",{"collectionId":17,"collectionName":18,"created":54,"created_by":13,"id":55,"name":56,"updated":57,"updated_by":13},"2026-03-04 08:48:07.088Z","brfbypclggbbkcx","WebSocket API","2026-04-10 16:13:40.594Z",{"collectionId":17,"collectionName":18,"created":59,"created_by":13,"id":60,"name":61,"updated":62,"updated_by":13},"2026-03-04 08:51:19.902Z","ybwrb9ksy12o89r","API Development","2026-04-10 16:14:35.541Z",{"collectionId":17,"collectionName":18,"created":64,"created_by":13,"id":65,"name":66,"updated":67,"updated_by":13},"2026-03-04 08:32:51.346Z","tmzmy6jyz1n35rr","Go Programming","2026-04-10 16:08:01.434Z",{"code":69,"collectionId":70,"collectionName":71,"created":72,"flag":73,"id":74,"is_default":75,"label":76,"updated":77},"en","pbc_1989393366","locales","2026-01-22 11:00:02.726Z","twemoji:flag-united-states","qv9c1llfov2d88z",false,"English","2026-04-10 15:42:46.825Z",{"category":79,"collectionId":80,"collectionName":81,"expand":82,"id":96,"views":97},"wqxt7ag2gn7xcmk","pbc_2105096300","school_blogs",{"category":83},{"blogIds":84,"collectionId":85,"collectionName":86,"created":87,"created_by":13,"id":79,"image":88,"image_alt":13,"image_path":89,"label":90,"name":91,"priority":92,"publish_at":93,"scheduled_at":13,"status":94,"updated":95,"updated_by":13},[],"sclcatblg987654321","school_category_blogs","2026-03-04 08:33:53.210Z","59ty92ns80w_15oc1implw.png","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclcatblg987654321\u002Fwqxt7ag2gn7xcmk\u002F59ty92ns80w_15oc1implw.png",{"en":91,"th":91},"Golang The Series",1,"2026-03-16 04:39:38.440Z","published","2026-04-25 02:32:15.470Z","lar2cqpq5juncim",254,"2q3wqkpq42ehz3a",[20,25,30,35,40,45,50,55,60,65],"2025-03-11 02:35:36.632Z","Learn how to use GraphQL Subscriptions with WebSocket in Go to build real-time APIs that respond to data changes instantly.","graphql-websocket-go-real-time-api","2026-04-22 07:11:46.549Z",{"en":102}]