Update examples
This commit is contained in:
parent
fbc2b98827
commit
9ee51dfc37
2
examples
2
examples
|
@ -1 +1 @@
|
||||||
Subproject commit 64e75d3c3f0acbbf62412f966727581e96f70e0e
|
Subproject commit 765997ea5dd6d004b027ec12967aa42253002434
|
|
@ -15,7 +15,7 @@ categories = ["network-programming", "asynchronous"]
|
||||||
async-graphql = { path = "../..", version = "=2.8.5" }
|
async-graphql = { path = "../..", version = "=2.8.5" }
|
||||||
|
|
||||||
warp = { version = "0.3.0", default-features = false, features = ["websocket"] }
|
warp = { version = "0.3.0", default-features = false, features = ["websocket"] }
|
||||||
futures-util = { version = "0.3.13", default-features = false }
|
futures-util = { version = "0.3.13", default-features = false, features = ["sink"] }
|
||||||
serde_json = "1.0.64"
|
serde_json = "1.0.64"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -3,6 +3,8 @@ use std::str::FromStr;
|
||||||
|
|
||||||
use async_graphql::http::{WebSocketProtocols, WsMessage};
|
use async_graphql::http::{WebSocketProtocols, WsMessage};
|
||||||
use async_graphql::{Data, ObjectType, Result, Schema, SubscriptionType};
|
use async_graphql::{Data, ObjectType, Result, Schema, SubscriptionType};
|
||||||
|
use futures_util::sink::Sink;
|
||||||
|
use futures_util::stream::Stream;
|
||||||
use futures_util::{future, StreamExt};
|
use futures_util::{future, StreamExt};
|
||||||
use warp::filters::ws;
|
use warp::filters::ws;
|
||||||
use warp::{Filter, Rejection, Reply};
|
use warp::{Filter, Rejection, Reply};
|
||||||
|
@ -172,8 +174,7 @@ pub async fn graphql_subscription_upgrade<Query, Mutation, Subscription, S>(
|
||||||
Query: ObjectType + 'static,
|
Query: ObjectType + 'static,
|
||||||
Mutation: ObjectType + 'static,
|
Mutation: ObjectType + 'static,
|
||||||
Subscription: SubscriptionType + 'static,
|
Subscription: SubscriptionType + 'static,
|
||||||
S: futures_util::Stream<Item = Result<warp::ws::Message, warp::Error>>
|
S: Stream<Item = Result<warp::ws::Message, warp::Error>> + Sink<warp::ws::Message>,
|
||||||
+ futures_util::Sink<warp::ws::Message>,
|
|
||||||
{
|
{
|
||||||
graphql_subscription_upgrade_with_data(websocket, protocol, schema, |_| async {
|
graphql_subscription_upgrade_with_data(websocket, protocol, schema, |_| async {
|
||||||
Ok(Default::default())
|
Ok(Default::default())
|
||||||
|
@ -195,8 +196,7 @@ pub async fn graphql_subscription_upgrade_with_data<Query, Mutation, Subscriptio
|
||||||
Subscription: SubscriptionType + 'static,
|
Subscription: SubscriptionType + 'static,
|
||||||
F: FnOnce(serde_json::Value) -> R + Send + 'static,
|
F: FnOnce(serde_json::Value) -> R + Send + 'static,
|
||||||
R: Future<Output = Result<Data>> + Send + 'static,
|
R: Future<Output = Result<Data>> + Send + 'static,
|
||||||
S: futures_util::Stream<Item = Result<warp::ws::Message, warp::Error>>
|
S: Stream<Item = Result<warp::ws::Message, warp::Error>> + Sink<warp::ws::Message>,
|
||||||
+ futures_util::Sink<warp::ws::Message>,
|
|
||||||
{
|
{
|
||||||
let (ws_sender, ws_receiver) = websocket.split();
|
let (ws_sender, ws_receiver) = websocket.split();
|
||||||
let _ = async_graphql::http::WebSocket::with_data(
|
let _ = async_graphql::http::WebSocket::with_data(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user