Describe the bug
Subscription performance depends on graphql url definition. If configured url is not ending in / executing subscription from playground query will return an error.
To Reproduce
Steps to reproduce the behavior:
subscription{
onReview(episode:EMPIRE){
commentary
stars
}
}{
"error": "Could not connect to websocket endpoint ws://localhost:5000/graphql/playground/... Please check if the endpoint url is correct."
}Expected behavior
Playground should say Listening..
Desktop (please complete the following information):
Additional context
Problem seems to be in combination of how url Playground in using to execute queries and how path comparation is implemented in SubscriptionMiddleware.IsValidPath method. Playground will always add / at the end of url. If server is configured with .UseGraphQL("/graphql"), SubscriptionMiddleware.IsValidPath will return false as "/graphql" and "/graphql/" are not equal. Interesting is that with same configuration of server url queries will executing if you send the both to /graphql and /graphql/ routes.
I got same issue: https://github.com/ChilliCream/hotchocolate/issues/1712 with details why
Track this one: https://github.com/ChilliCream/hotchocolate/issues/1630
For now workaround is:
app.UseWebSockets()
.UseGraphQL(new QueryMiddlewareOptions
{
Path = "/graphql",
SubscriptionPath = "/graphql/"
})
.UseGraphiQL("/graphql")
Since as @sergeyshaykhullin pointed out this is a duplicate we are gonna close this one and mark it as duplicate.
Most helpful comment
I got same issue: https://github.com/ChilliCream/hotchocolate/issues/1712 with details why
Track this one: https://github.com/ChilliCream/hotchocolate/issues/1630
For now workaround is: