I tried to complete a simple SSE example and passed the test using curl, but discovered the following problems while writing the go test case.
I found an unknown bug in client.SSE that will block forever once it is called. This bug appears to be for subscriptions only, as the two test cases in codegen/testserver/singlefile/defer_test.go work normally. I did not find an SSE test case for subscription in the project.
For Example:
server := handler.New(graph.NewExecutableSchema(graph.Config{
Resolvers: &graph.Resolver{},
}))
server.AddTransport(transport.SSE{})
c := client.New(server)
sse := c.SSE(context.Background(), `subscription {
onTodoChange {
action oldValue { id text done } newValue { id text done }
}
}`)
// Never get here
var resp any
fmt.Println(sse.Next(&resp), resp)
type Todo {
id: ID!
text: String!
done: Boolean!
}
enum TodoChangeAction {
New
ToggleDone
}
type TodoChangeMessage {
newValue: Todo
oldValue: Todo
action: TodoChangeAction!
}
type Subscription {
onTodoChange: TodoChangeMessage!
}
versions
go run github.com/99designs/gqlgen version? v0.17.49-dev
What happened?
I tried to complete a simple SSE example and passed the test using curl, but discovered the following problems while writing the go test case.
I found an unknown bug in client.SSE that will block forever once it is called. This bug appears to be for subscriptions only, as the two test cases in
codegen/testserver/singlefile/defer_test.go
work normally. I did not find an SSE test case for subscription in the project.For Example:
Complete recurring use cases can be found here https://github.com/o8x/gqlgen/tree/sse-example/_examples/sse
What did you expect?
blocking in the
sse.Next()
methodMinimal graphql.schema and models to reproduce
versions
go run github.com/99designs/gqlgen version
? v0.17.49-devgo version
? go version go1.22.3 darwin/arm64