Hi, thanks for your question.
First, we configure the WebSockets through `src.AddTransport` here.
Then, define the schema for subscription and hit the command, `go run github.com/99designs/gqlgen
`.
https://github.com/manakuro/golang-graphql-subscriptions/blob/main/graph/schema.graphqls#L14-L16
This automatically creates the resolver called `MessageCreated` here.
https://github.com/manakuro/golang-graphql-subscriptions/blob/main/graph/schema.resolvers.go#L54
In the `MessageCreated`, we store a channel to consume a message from Redis Stream.
https://github.com/manakuro/golang-graphql-subscriptions/blob/main/graph/schema.resolvers.go#L58
After a message is created, the Redis Stream loads the message and sent it to the subscription through the channel here.
https://github.com/manakuro/golang-graphql-subscriptions/blob/main/graph/resolver.go#L49-L51
Then, the client can fetch the message through the subscription.
https://github.com/manakuro/golang-graphql-subscriptions/blob/main/frontend/src/Component.tsx#L20
The process is repeated every time message is created.