{"id":2495,"date":"2021-02-02T20:33:00","date_gmt":"2021-02-02T19:33:00","guid":{"rendered":"https:\/\/frachtwerk.fw-web.space\/?p=2495"},"modified":"2024-09-10T13:56:39","modified_gmt":"2024-09-10T13:56:39","slug":"modern-reactive-web-apis-with-graphql-go-and-server-sent-events-part-2","status":"publish","type":"post","link":"https:\/\/frachtwerk.fw-web.space\/modern-reactive-web-apis-with-graphql-go-and-server-sent-events-part-2\/","title":{"rendered":"Modern, reactive web APIs with GraphQL, Go and Server-Sent Events \u2013 Part 2"},"content":{"rendered":"\n

In the previous<\/a> part, concepts and benefits of GraphQL and GraphQL Subscriptions<\/a> were presented and proposed as a modern, highly flexible alternative for designing web APIs.<\/p>\n\n\n\n

In this post, we are going to look at actual code. For demonstration purposes, a small single-page application (SPA) is built as an example. It can serve as a cleanly structured starting point for new apps based on the proposed tech stack.<\/p>\n\n\n\n

Code<\/strong>: muety\/go-graphql-sse-example<\/a><\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

What to build?<\/h2>\n\n\n\n

The demo web app built in the context of this article comprised of a client-side frontend, built with VueJS<\/a> and a server-side component built with Go. The two components interact with each other through a GraphQL API, which additionally offers the option to subscribe to data updates using Server-Sent Events<\/a>.
With this demo app, we aim to mimic the functionality of a very basic, minimalist food ordering system. Customers can choose from a list of food products and place their orders. They are shown a waiting number an estimated processing time for their orders and are notified once the order is ready to be picked up. One the other side there is the kiosk operator, who views a live dashboard of currently pending orders, which appear just as they are being placed.<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

Technology Stack<\/h2>\n\n\n\n

In summary, the following technologies are used:<\/p>\n\n\n\n