Bump poem to 1.2.1
This commit is contained in:
parent
ed8449beec
commit
781efa8ad1
|
@ -32,7 +32,7 @@ async-graphql-parser = { path = "parser", version = "3.0.13" }
|
|||
async-stream = "0.3.0"
|
||||
async-trait = "0.1.48"
|
||||
fnv = "1.0.7"
|
||||
futures-util = { version = "0.3.18", default-features = false, features = ["io", "sink"] }
|
||||
futures-util = { version = "0.3.0", default-features = false, features = ["io", "sink"] }
|
||||
indexmap = "1.6.2"
|
||||
once_cell = "1.7.2"
|
||||
pin-project-lite = "0.2.6"
|
||||
|
|
2
examples
2
examples
|
@ -1 +1 @@
|
|||
Subproject commit f9116e9029f6d57cea22c139c3e5fd952b774979
|
||||
Subproject commit 551868559b7b2c0db3d10315219be47ec1004c98
|
|
@ -18,7 +18,7 @@ actix-http = "3.0.0-beta.15"
|
|||
actix-web = { version = "4.0.0-beta.14", default-features = false }
|
||||
actix-web-actors = "4.0.0-beta.8"
|
||||
async-channel = "1.6.1"
|
||||
futures-util = { version = "0.3.17", default-features = false }
|
||||
futures-util = { version = "0.3.0", default-features = false }
|
||||
serde_json = "1.0.64"
|
||||
serde_urlencoded = "0.7.0"
|
||||
futures-channel = "0.3.13"
|
||||
|
|
|
@ -21,5 +21,5 @@ http-body = "0.4.2"
|
|||
serde_json = "1.0.66"
|
||||
serde_urlencoded = "0.7.0"
|
||||
tokio-util = { version = "0.6.7", features = ["io", "compat"] }
|
||||
futures-util = "0.3.13"
|
||||
futures-util = "0.3.0"
|
||||
tower-service = "0.3"
|
||||
|
|
|
@ -14,8 +14,8 @@ categories = ["network-programming", "asynchronous"]
|
|||
[dependencies]
|
||||
async-graphql = { path = "../..", version = "3.0.13" }
|
||||
|
||||
poem = { version = "1.0.23", features = ["websocket"] }
|
||||
futures-util = { version = "0.3.13", default-features = false }
|
||||
poem = { version = "1.2.1", features = ["websocket"] }
|
||||
futures-util = { version = "0.3.0", default-features = false }
|
||||
serde_json = "1.0.66"
|
||||
tokio-util = { version = "0.6.7", features = ["compat"] }
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use async_graphql::http::MultipartOptions;
|
|||
use poem::error::BadRequest;
|
||||
use poem::http::{header, Method};
|
||||
use poem::web::Query;
|
||||
use poem::{async_trait, Error, FromRequest, Request, RequestBody, Result};
|
||||
use poem::{async_trait, FromRequest, Request, RequestBody, Result};
|
||||
use tokio_util::compat::TokioAsyncReadCompatExt;
|
||||
|
||||
/// An extractor for GraphQL request.
|
||||
|
@ -42,8 +42,6 @@ pub struct GraphQLRequest(pub async_graphql::Request);
|
|||
|
||||
#[async_trait]
|
||||
impl<'a> FromRequest<'a> for GraphQLRequest {
|
||||
type Error = Error;
|
||||
|
||||
async fn from_request(req: &'a Request, body: &mut RequestBody) -> Result<Self> {
|
||||
Ok(GraphQLRequest(
|
||||
GraphQLBatchRequest::from_request(req, body)
|
||||
|
@ -60,8 +58,6 @@ pub struct GraphQLBatchRequest(pub async_graphql::BatchRequest);
|
|||
|
||||
#[async_trait]
|
||||
impl<'a> FromRequest<'a> for GraphQLBatchRequest {
|
||||
type Error = Error;
|
||||
|
||||
async fn from_request(req: &'a Request, body: &mut RequestBody) -> Result<Self> {
|
||||
if req.method() == Method::GET {
|
||||
let req = Query::from_request(req, body).await?.0;
|
||||
|
@ -78,7 +74,8 @@ impl<'a> FromRequest<'a> for GraphQLBatchRequest {
|
|||
body.take()?.into_async_read().compat(),
|
||||
MultipartOptions::default(),
|
||||
)
|
||||
.await?,
|
||||
.await
|
||||
.map_err(BadRequest)?,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,9 +44,9 @@ where
|
|||
Mutation: ObjectType + 'static,
|
||||
Subscription: SubscriptionType + 'static,
|
||||
{
|
||||
type Output = Result<GraphQLBatchResponse>;
|
||||
type Output = GraphQLBatchResponse;
|
||||
|
||||
async fn call(&self, req: Request) -> Self::Output {
|
||||
async fn call(&self, req: Request) -> Result<Self::Output> {
|
||||
let (req, mut body) = req.split();
|
||||
let req = GraphQLBatchRequest::from_request(&req, &mut body).await?;
|
||||
Ok(GraphQLBatchResponse(self.schema.execute_batch(req.0).await))
|
||||
|
|
|
@ -8,7 +8,9 @@ use futures_util::stream::{SplitSink, SplitStream};
|
|||
use futures_util::{Future, Sink, SinkExt, Stream, StreamExt};
|
||||
use poem::http::StatusCode;
|
||||
use poem::web::websocket::{Message, WebSocket};
|
||||
use poem::{http, Endpoint, FromRequest, IntoResponse, Request, RequestBody, Response, Result};
|
||||
use poem::{
|
||||
http, Endpoint, Error, FromRequest, IntoResponse, Request, RequestBody, Response, Result,
|
||||
};
|
||||
|
||||
/// A GraphQL protocol extractor.
|
||||
///
|
||||
|
@ -18,9 +20,7 @@ pub struct GraphQLProtocol(pub WebSocketProtocols);
|
|||
|
||||
#[poem::async_trait]
|
||||
impl<'a> FromRequest<'a> for GraphQLProtocol {
|
||||
type Error = StatusCode;
|
||||
|
||||
async fn from_request(req: &'a Request, _body: &mut RequestBody) -> Result<Self, Self::Error> {
|
||||
async fn from_request(req: &'a Request, _body: &mut RequestBody) -> Result<Self> {
|
||||
req.headers()
|
||||
.get(http::header::SEC_WEBSOCKET_PROTOCOL)
|
||||
.and_then(|value| value.to_str().ok())
|
||||
|
@ -30,7 +30,7 @@ impl<'a> FromRequest<'a> for GraphQLProtocol {
|
|||
.find_map(|p| WebSocketProtocols::from_str(p.trim()).ok())
|
||||
})
|
||||
.map(Self)
|
||||
.ok_or(StatusCode::BAD_REQUEST)
|
||||
.ok_or_else(|| Error::new_with_status(StatusCode::BAD_REQUEST))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,9 +85,9 @@ where
|
|||
Mutation: ObjectType + 'static,
|
||||
Subscription: SubscriptionType + 'static,
|
||||
{
|
||||
type Output = Result<Response>;
|
||||
type Output = Response;
|
||||
|
||||
async fn call(&self, req: Request) -> Self::Output {
|
||||
async fn call(&self, req: Request) -> Result<Self::Output> {
|
||||
let (req, mut body) = req.split();
|
||||
let websocket = WebSocket::from_request(&req, &mut body).await?;
|
||||
let protocol = GraphQLProtocol::from_request(&req, &mut body).await?;
|
||||
|
|
|
@ -18,7 +18,7 @@ websocket = ["tide-websockets"]
|
|||
[dependencies]
|
||||
async-graphql = { path = "../..", version = "3.0.13" }
|
||||
async-trait = "0.1.48"
|
||||
futures-util = "0.3.13"
|
||||
futures-util = "0.3.0"
|
||||
serde_json = "1.0.64"
|
||||
|
||||
tide = { version = "0.16.0", default-features = false, features = ["h1-server"] }
|
||||
|
|
|
@ -15,7 +15,7 @@ categories = ["network-programming", "asynchronous"]
|
|||
async-graphql = { path = "../..", version = "3.0.13" }
|
||||
|
||||
warp = { version = "0.3.0", default-features = false, features = ["websocket"] }
|
||||
futures-util = { version = "0.3.13", default-features = false, features = ["sink"] }
|
||||
futures-util = { version = "0.3.0", default-features = false, features = ["sink"] }
|
||||
serde_json = "1.0.64"
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
Loading…
Reference in New Issue
Block a user