pub fn graphql_subscription_with_data<Query, Mutation, Subscription, F>(
    schema: Schema<Query, Mutation, Subscription>,
    initializer: Option<F>,
) -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone
where
    Query: ObjectType + Sync + Send + 'static,
    Mutation: ObjectType + Sync + Send + 'static,
    Subscription: SubscriptionType + Send + Sync + 'static,
    F: FnOnce(serde_json::Value) -> FieldResult<Data> + Send + Sync + Clone + 'static,
{
    warp::any()
        .and(warp::ws())
        .and(warp::any().map(move || schema.clone()))
        .and(warp::any().map(move || initializer.clone()))
        .map(
            |ws: ws::Ws, schema: Schema<Query, Mutation, Subscription>, initializer: Option<F>| {
                ws.on_upgrade(move |websocket| {
                    let (ws_sender, ws_receiver) = websocket.split();

                    async move {
                        let _ = async_graphql::http::WebSocket::with_data(
                            schema,
                            ws_receiver
                                .take_while(|msg| future::ready(msg.is_ok()))
                                .map(Result::unwrap)
                                .map(ws::Message::into_bytes),
                            initializer,
                        )
                        .map(ws::Message::text)
                        .map(Ok)
                        .forward(ws_sender)
                        .await;
                    }
                })
            },
        )
        .map(|reply| warp::reply::with_header(reply, "Sec-WebSocket-Protocol", "graphql-ws"))
}
/// GraphQL subscription filter
///
/// Specifies that a function converts the init payload to data.
GraphQL subscription filter
Specifies that a function converts the init payload to data.
GraphQL subscription filter Specifies that a function converts the init payload to data .
pub fn graphql_subscription_with_data<Query, Mutation, Subscription, F>(
    schema: Schema<Query, Mutation, Subscription>,
    initializer: Option<F>,
) -> impl Filter<Extract = (impl Reply,), Error = Rejection> + Clone
where
    Query: ObjectType + Sync + Send + 'static,
    Mutation: ObjectType + Sync + Send + 'static,
    Subscription: SubscriptionType + Send + Sync + 'static,
    F: FnOnce(serde_json::Value) -> FieldResult<Data> + Send + Sync + Clone + 'static,
{
    warp::any()
        .and(warp::ws())
        .and(warp::any().map(move || schema.clone()))
        .and(warp::any().map(move || initializer.clone()))
        .map(
            |ws: ws::Ws, schema: Schema<Query, Mutation, Subscription>, initializer: Option<F>| {
                ws.on_upgrade(move |websocket| {
                    let (ws_sender, ws_receiver) = websocket.split();
                    async move {
                        let _ = async_graphql::http::WebSocket::with_data(
                            schema,
                            ws_receiver
                                .take_while(|msg| future::ready(msg.is_ok()))
                                .map(Result::unwrap)
                                .map(ws::Message::into_bytes),
                            initializer,
                        )
                        .map(ws::Message::text)
                        .map(Ok)
                        .forward(ws_sender)
                        .await;
                    }
                })
            },
        )
        .map(|reply| warp::reply::with_header(reply, "Sec-WebSocket-Protocol", "graphql-ws"))
}
pub fn graphql_subscription_with_data < Query , Mutation , Subscription , F > ( schema : Schema < Query , Mutation , Subscription > , initializer : Option < F > , ) -> impl Filter < Extract = ( impl Reply , ) , Error = Rejection > + Clone where Query : ObjectType + Sync + Send + ' static , Mutation : ObjectType + Sync + Send + ' static , Subscription : SubscriptionType + Send + Sync + ' static , F : FnOnce ( serde_json :: Value ) -> FieldResult < Data > + Send + Sync + Clone + ' static , { warp :: any ( ) . and ( warp :: ws ( ) ) . and ( warp :: any ( ) . map ( move | | schema . clone ( ) ) ) . and ( warp :: any ( ) . map ( move | | initializer . clone ( ) ) ) . map ( | ws : ws :: Ws , schema : Schema < Query , Mutation , Subscription > , initializer : Option < F > | { ws . on_upgrade ( move | websocket | { let ( ws_sender , ws_receiver ) = websocket . split ( ) ; async move { let _ = async_graphql :: http :: WebSocket :: with_data ( schema , ws_receiver . take_while ( | msg | future :: ready ( msg . is_ok ( ) ) ) . map ( Result :: unwrap ) . map ( ws :: Message :: into_bytes ) , initializer , ) . map ( ws :: Message :: text ) . map ( Ok ) . forward ( ws_sender ) . await ; } } ) } , ) . map ( | reply | warp :: reply :: with_header ( reply , " " , " " ) ) }
GraphQL subscription filter
Specifies that a function converts the init payload to data.
GraphQL subscription filter Specifies that a function converts the init payload to data .
schema
Schema<Query, Mutation, Subscription>
initializer
Option<F>
schema
Schema<Query, Mutation, Subscription>
initializer
Option<F>