-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Context cancelled when using @defer #2771
Comments
Hi Adam, When the support for defer was implemented, apollo/client had a lot of bugs, urql worked fine on another hand. Here is patched version of the GraphiQL playground that supports SSE and defer works properly https://gist.github.com/UnAfraid/c2f9ed63332c47a2d588213fdbcfd688 |
Thanks for the help! I tried the script you sent but it keeps giving me
I do have the transports added:
I'll try to dig into this more deeply in a couple of weeks when I get another chance. |
Here is an example i just tested and it works for me https://github.com/UnAfraid/wg-ui/blob/master/pkg/api/router.go#L65-L79. gqlHandler := gqlhandler.New(exec.NewExecutableSchema(executableSchemaConfig))
gqlHandler.AddTransport(transport.Websocket{
InitFunc: authHandler.WebsocketMiddleware(),
KeepAlivePingInterval: 10 * time.Second,
Upgrader: websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return checkOrigin(r, conf.SubscriptionAllowedOrigins)
},
},
})
gqlHandler.AddTransport(transport.SSE{})
gqlHandler.AddTransport(transport.Options{})
gqlHandler.AddTransport(transport.GET{})
gqlHandler.AddTransport(transport.POST{})
gqlHandler.AddTransport(transport.MultipartForm{}) You can test with curl to make sure server replies with SSE curl 'http://localhost:8080/query' \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H 'Connection: keep-alive' \
-H 'accept: text/event-stream' \
-H 'content-type: application/json; charset=utf-8' \
--data-raw '{"query":"query users {\n users{\n ... user @defer\n }\n}\n\nfragment user on User {\n id\n servers {\n ... on Server @defer {\n id\n }\n }\n}","operationName":"users"}' The response should be similar to that
|
What happened?
I upgraded to the latest gqlgen generator and am attempting to use a defer directive in a query. The request works fine without the directive. When I used the directive, the initial response is as expected, "totalValue" is null and "hasNext" is included and is true. When I log the "totalValue" resolver, it is saying that the incoming context is cancelled. Attempted to use a new context just to get through the error and it still doesn't return anything to the caller.
I'm did this through the included graphql playground as well as through the
@apollo/client
.What did you expect?
I expected the call to complete will the non-deferred data and then the deferred data to be returned in a second response. Here is the PR I'm modelling the expectation from: #2642 by @StevenACoffman
Minimal graphql.schema and models to reproduce
versions
The text was updated successfully, but these errors were encountered: