Closed
Description
I have
async fn subscriptions(
req: HttpRequest,
stream: web::Payload,
schema: web::Data<Schema>,
) -> Result<HttpResponse, Error> {
let context = Context::new()
let schema = schema.into_inner();
let config = ConnectionConfig::new(context);
let config = config.with_keep_alive_interval(Duration::from_secs(15));
subscriptions_handler(req, stream, schema, config).await
}
but subscriptions_handler(req, stream, schema, config).await
the config
argument gives error
expected a `FnOnce<(HashMap<std::string::String, InputValue>,)>` closure, found `ConnectionConfig<context::Context>`
the trait `FnOnce<(HashMap<std::string::String, InputValue>,)>` is not implemented for `ConnectionConfig<context::Context>`
the trait `juniper_graphql_ws::Init<S, CtxT>` is implemented for `juniper_graphql_ws::ConnectionConfig<CtxT>`
required for `ConnectionConfig<context::Context>` to implement `juniper_graphql_ws::Init<DefaultScalarValue, context::Context>`
Activity
tyranron commentedon Sep 21, 2023
@kimutaiRop yes, there are interoperability problems between old
juniper_graphql_ws
crate and newjuniper_graphql_transport_ws
crate introduced in #1158. Such types asConnectionConfig
are fully duplicated, thus represent different types. Furthermore, in #1158 no solution forjuniper_actix
crate to integrate newjuniper_graphql_transport_ws
crate was landed, so what you're trying to do is just not possible.I've polished interoperability a bit in #1191, and introduced
juniper_actix
crate integration. So now you could just do:and it should work just fine, as showed in the
juniper_actix/example/subscription.rs
.It also implements protocol auto-selection out-of-the-box, based on the
Sec-Websocket-Protocol
HTTP header value.After #1191 I do also plan some more adjustments to things, but they should be much easier to catch up with:
juniper_graphql_ws
andjuniper_graphql_transport_ws
, since they share a substantial codebase anyway.juniper_actix::subscritions
via actorlessactix-ws
crate instead of the currentactix-web-actors::ws
one. The whole thing with actors cooperates very badly withjuniper_graphql_ws
state machine, introducing too excessive polling, which leads to panics and abnormal WebSocket closures instead of normal ones. It also gives a feeling of fighting with actors, trying to pair them withStream
/Sink
, instead of easing it. So, the actorlessactix-ws
crate should go just fine, as we have in thejuniper_warp
crate.kimutaiRop commentedon Sep 22, 2023
@tyranron amazing thanks that worked.. looking forward to the coming changes seem like will make using the all thing way easier
juniper_graphql_transport_ws
andjuniper_graphql_ws
crates (#1022) #1196actix-ws
forjuniper_actix
subscriptions #1197