[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"academy-blog-translations-none":3,"academy-blogs-en-1-1-all-websocket-graphql-subscriptions-golang-all--*":4},{},{"data":5,"meta":74},[6],{"categoryId":7,"collectionId":8,"collectionName":9,"content":10,"createBy":11,"createDate":12,"created":13,"description":14,"expand":15,"group":66,"id":66,"image":67,"imageAlt":68,"imagePath":69,"keywordIds":70,"langId":62,"publishDate":50,"scheduleDate":12,"slug":71,"status":28,"title":68,"updateBy":11,"updated":72,"views":73},"wqxt7ag2gn7xcmk","sclblg987654321","school_blog","\u003Cp>In this episode, we’ll explore GraphQL Subscriptions — a modern approach to building real-time applications using WebSocket that offers flexible control over data structure and avoids the common issue of over-fetching data seen with traditional REST APIs.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Ideal use cases include:\u003C\u002Fp>\u003Cul>\u003Cli>🟢 Real-time Chat Systems\u003C\u002Fli>\u003Cli>🔔 Notifications\u003C\u002Fli>\u003Cli>📊 Live Dashboards\u003C\u002Fli>\u003C\u002Ful>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>🤔 Why Use GraphQL Subscriptions?\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cfigure class=\"table\">\u003Ctable>\u003Cthead>\u003Ctr>\u003Cth>Benefit\u003C\u002Fth>\u003Cth>Description\u003C\u002Fth>\u003C\u002Ftr>\u003C\u002Fthead>\u003Ctbody>\u003Ctr>\u003Ctd>✅ Send only the necessary data\u003C\u002Ftd>\u003Ctd>Clients can specify exactly which fields they want\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>🔄 Real-time updates\u003C\u002Ftd>\u003Ctd>Receive data immediately when changes happen\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>❌ No need for polling\u003C\u002Ftd>\u003Ctd>Avoid calling the same REST API every few seconds\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>🛠 Flexible &amp; maintainable\u003C\u002Ftd>\u003Ctd>Schema changes are easier to manage and deploy\u003C\u002Ftd>\u003C\u002Ftr>\u003C\u002Ftbody>\u003C\u002Ftable>\u003C\u002Ffigure>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>🧪 GraphQL Subscriptions with WebSocket in Go\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Here’s a basic server setup using \u003Ccode inline=\"\">gqlgen\u003C\u002Fcode>, a popular Go library for building GraphQL servers.\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-go\">package main\n\nimport (\n    \"log\"\n    \"net\u002Fhttp\"\n\n    \"github.com\u002F99designs\u002Fgqlgen\u002Fgraphql\u002Fhandler\"\n    \"github.com\u002F99designs\u002Fgqlgen\u002Fgraphql\u002Fplayground\"\n    \"github.com\u002Fyourusername\u002Fyourproject\u002Fgraph\"\n    \"github.com\u002Fyourusername\u002Fyourproject\u002Fgraph\u002Fgenerated\"\n)\n\nfunc main() {\n    srv := handler.NewDefaultServer(\n        generated.NewExecutableSchema(\n            generated.Config{Resolvers: &amp;graph.Resolver{}},\n        ),\n    )\n\n    http.Handle(\"\u002F\", playground.Handler(\"GraphQL Playground\", \"\u002Fquery\"))\n    http.Handle(\"\u002Fquery\", srv)\n\n    log.Println(\"🚀 Server running at http:\u002F\u002Flocalhost:8080\u002F\")\n    log.Fatal(http.ListenAndServe(\":8080\", nil))\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>✅ Note: This example uses gqlgen, one of the most efficient tools to create GraphQL servers in Go.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>🗨 Sample Subscription Query\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-graphql\">subscription {\n  messageAdded {\n    id\n    content\n    sender\n  }\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>Whenever a new message is added (e.g., a user sends a chat), all clients subscribed to \u003Ccode inline=\"\">messageAdded\u003C\u002Fcode> will receive the new data instantly via WebSocket.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>⚙️ Connecting to WebSocket (Frontend with Apollo Client)\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>You can use tools like Apollo Client, which natively supports GraphQL subscriptions:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext language-js\">import { WebSocketLink } from \"@apollo\u002Fclient\u002Flink\u002Fws\";\nimport { ApolloClient, InMemoryCache } from \"@apollo\u002Fclient\";\n\nconst wsLink = new WebSocketLink({\n  uri: `ws:\u002F\u002Flocalhost:8080\u002Fquery`,\n  options: {\n    reconnect: true\n  }\n});\n\nconst client = new ApolloClient({\n  link: wsLink,\n  cache: new InMemoryCache()\n});\n\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>💡 Apollo handles \u003Ccode inline=\"\">connection_init\u003C\u002Fcode>, \u003Ccode inline=\"\">ping\u002Fpong\u003C\u002Fcode>, and automatic reconnect out of the box.\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Chr>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>🧠 Summary\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Using GraphQL Subscriptions with WebSocket is a powerful approach for building real-time applications with better control over data flow and structure. Benefits include:\u003C\u002Fp>\u003Cul>\u003Cli>Fine-grained payload control\u003C\u002Fli>\u003Cli>No repetitive polling\u003C\u002Fli>\u003Cli>Easy schema adjustments\u003C\u002Fli>\u003Cli>Seamless integration with Go via \u003Ccode inline=\"\">gqlgen\u003C\u002Fcode>\u003C\u002Fli>\u003C\u002Ful>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>🚀 Give it a Try!\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>Try applying this to build:\u003C\u002Fp>\u003Cul>\u003Cli>✅ A real-time group chat\u003C\u002Fli>\u003Cli>✅ Order or system notifications\u003C\u002Fli>\u003Cli>✅ Live reporting dashboard\u003C\u002Fli>\u003C\u002Ful>\u003Cp>&nbsp;\u003C\u002Fp>\u003Ch2>🔜 Next EP\u003C\u002Fh2>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>EP.86: Managing WebSocket Connections with Redis Pub\u002FSub\u003C\u002Fp>\u003Cp>We’ll learn how to scale your WebSocket Server across multiple instances using Redis Pub\u002FSub to keep all users in sync — no matter which server they're connected to!\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp data-start=\"498\" data-end=\"834\">\u003Cstrong>Read more\u003C\u002Fstrong>\u003C\u002Fp>\u003Cul>\u003Cli>\u003Cp data-start=\"498\" data-end=\"834\">\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.superdev.school\u002Fblogs\u002Fcategories\u002FGolang\">\u003Cstrong>Golang The Series\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>\u003C\u002Fli>\u003Cli>\u003Cp data-start=\"498\" data-end=\"834\">\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.superdev.school\u002Fblogs\u002Fcategories\u002FJS2GO\">\u003Cstrong>JS2GO\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>\u003C\u002Fli>\u003Cli>\u003Cp data-start=\"498\" data-end=\"834\">\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.superdev.school\u002Fen\u002Fblogs\u002Fcategories\u002FTailwind%20CSS\">\u003Cstrong>10 Eps That Will Make You a Pro Tailwind CSS Overnight\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>\u003C\u002Fli>\u003C\u002Ful>\u003Cp>\u003Cstrong>🔵 Facebook: \u003C\u002Fstrong>\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.facebook.com\u002Fsuperdev.school.th\">\u003Cstrong>Superdev School &nbsp;(Superdev)\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>\u003Cp>\u003Cstrong>📸 Instagram: \u003C\u002Fstrong>\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.instagram.com\u002Fsuperdevschool\u002F\">\u003Cstrong>superdevschool\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>\u003Cp>\u003Cstrong>🎬 TikTok: \u003C\u002Fstrong>\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.tiktok.com\u002F@superdevschool\">\u003Cstrong>superdevschool\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>\u003Cp class=\"\" data-start=\"5978\" data-end=\"6095\">\u003Cstrong>🌐 Website: \u003C\u002Fstrong>\u003Ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\u002F\u002Fwww.superdev.school\u002F\">\u003Cstrong>www.superdev.school\u003C\u002Fstrong>\u003C\u002Fa>\u003C\u002Fp>","r8v4zgsahjuwpeb","","2026-03-04 08:46:53.785Z","Learn how to use GraphQL Subscriptions with WebSocket in Go to build real-time applications with flexible data structures, like Chat, Notifications, and Dashboards.",{"categoryId":16,"keywordIds":30,"langId":57},{"blogIds":17,"collectionId":18,"collectionName":19,"createBy":20,"created":21,"id":7,"image":22,"imageAlt":12,"imagePath":23,"label":24,"name":25,"priority":26,"publishDate":27,"scheduleDate":12,"status":28,"updateBy":20,"updated":29},[],"sclcatblg987654321","school_category_blog","oplnwslvnmx5axc","2026-03-04 08:33:53.210Z","59ty92ns80w_15oc1implw.png","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclcatblg987654321\u002Fwqxt7ag2gn7xcmk\u002F59ty92ns80w_15oc1implw.png",{"en":25,"th":25},"Golang The Series",1,"2026-03-16 04:39:38.440Z","Publish","2026-03-17 06:07:59.733Z",[31,38,43,47,52],{"collectionId":32,"collectionName":33,"createBy":12,"created":34,"id":35,"publishDate":36,"scheduleDate":12,"status":28,"title":37,"updateBy":12,"updated":34},"sclkey987654321","school_keyword","2026-03-04 08:34:00.920Z","ecac9y661or1xka","2025-01-27 04:42:34.661Z","WebSocket",{"collectionId":32,"collectionName":33,"createBy":12,"created":39,"id":40,"publishDate":41,"scheduleDate":12,"status":28,"title":42,"updateBy":12,"updated":39},"2026-03-04 08:20:11.547Z","ey3puyme01a9bsw","2026-01-28 00:54:28.566Z","Go",{"collectionId":32,"collectionName":33,"createBy":12,"created":44,"id":45,"publishDate":41,"scheduleDate":12,"status":28,"title":46,"updateBy":12,"updated":44},"2026-03-04 08:20:14.253Z","ah6lvy4x8qe08l5","Golang",{"collectionId":32,"collectionName":33,"createBy":12,"created":48,"id":49,"publishDate":50,"scheduleDate":12,"status":28,"title":51,"updateBy":12,"updated":48},"2026-03-04 08:46:53.342Z","5ac1xgod1ehyqva","2025-09-04 02:18:08.395Z","GraphQL Subscriptions",{"collectionId":32,"collectionName":33,"createBy":12,"created":53,"id":54,"publishDate":55,"scheduleDate":12,"status":28,"title":56,"updateBy":12,"updated":53},"2026-03-04 08:45:10.982Z","dqqa1njvmvzgknq","2025-12-08 02:14:19.907Z","Real-time Application",{"code":58,"collectionId":59,"collectionName":60,"createAt":61,"id":62,"is_default":63,"language":64,"updateAt":65},"en","pbc_1989393366","locale","2026-01-22 11:00:02.726Z","qv9c1llfov2d88z",false,"English","2026-02-05 10:48:59.032Z","l8x8gn84qk502l7","142_11zon_8gdjjnwoch.webp","EP.85 Building a WebSocket Server with GraphQL Subscriptions in Golang","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclblg987654321\u002Fl8x8gn84qk502l7\u002F142_11zon_8gdjjnwoch.webp",[35,40,45,49,54],"websocket-graphql-subscriptions-golang","2026-03-04 08:46:54.111Z",210,{"pagination":75},{"page":26,"pageSize":26,"pageCount":26,"total":26}]