I want to write a Subscription resolver
Through some issue searching I found a link to this: https://github.com/99designs/gqlgen/blob/master/example/chat/resolvers.go#L115-L150
That's what I'm working off of currently. It would be useful to have some part of the docs touch on subscriptions.
While the chat example is a good starting point, it misses in my opinion two important parts:
gqlgen never being able to terminate the internal go routine.go func() {
<-ctx.Done()
r.mu.Lock()
delete(room.Observers, id)
close(events) // <-
r.mu.Unlock()
}()
r.mu.Lock()
for _, observer := range room.Observers {
if observer.Username == "" || observer.Username == message.CreatedBy {
select {
case observer.Message <- &message:
default:
log.Printf("could not send message to %v\n", observer.Username)
}
}
}
r.mu.Unlock()
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@vektah is anyone working on this? I need to create a gql subscription and if no one is working on it, I will write some basic documentation once I figure it out
Yes, it would be nice to have some documentation on subscriptions. I have been trying to figure out how they work.
The only other reference I can find is https://www.freecodecamp.org/news/https-medium-com-anshap1719-graphql-subscriptions-with-go-gqlgen-and-mongodb-5e008fc46451/
The only other reference I can find is https://www.freecodecamp.org/news/https-medium-com-anshap1719-graphql-subscriptions-with-go-gqlgen-and-mongodb-5e008fc46451/
I got them working with arsmn's fork for gofiber framework. However, I am having an issue where I get an error whenever a user abruptly closes the subscription by closing the browser window/tab
Most helpful comment
@vektah is anyone working on this? I need to create a gql subscription and if no one is working on it, I will write some basic documentation once I figure it out