diff --git a/examples b/examples index 19a42619..f9eb27f1 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 19a426191a60334c7c7375188d87d68a2647c7bf +Subproject commit f9eb27f12d4ee9d6cd1c810ab9858aa178a567b1 diff --git a/integrations/axum/Cargo.toml b/integrations/axum/Cargo.toml index 50fc099f..3a6c161c 100644 --- a/integrations/axum/Cargo.toml +++ b/integrations/axum/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "async-graphql-axum" version = "2.9.12" +authors = ["sunli "] edition = "2018" +description = "async-graphql for axum" +license = "MIT/Apache-2.0" +documentation = "https://docs.rs/async-graphql-poem/" +homepage = "https://github.com/async-graphql/async-graphql" +repository = "https://github.com/async-graphql/async-graphql" +keywords = ["futures", "async", "graphql", "poem"] +categories = ["network-programming", "asynchronous"] [dependencies] async-graphql = { path = "../..", version = "=2.9.12" } diff --git a/integrations/poem/Cargo.toml b/integrations/poem/Cargo.toml index 8d986c4d..04ae358b 100644 --- a/integrations/poem/Cargo.toml +++ b/integrations/poem/Cargo.toml @@ -15,7 +15,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-graphql = { path = "../..", version = "=2.9.12" } -poem = { version = "0.3.6", features = ["websocket"] } +poem = { version = "0.4.5", features = ["websocket"] } futures-util = { version = "0.3.13", default-features = false } serde_json = "1.0.66" tokio-util = { version = "0.6.7", features = ["compat"] } diff --git a/integrations/poem/src/extractor.rs b/integrations/poem/src/extractor.rs index fc9434c8..ed9e36c3 100644 --- a/integrations/poem/src/extractor.rs +++ b/integrations/poem/src/extractor.rs @@ -12,7 +12,7 @@ use tokio_util::compat::TokioAsyncReadCompatExt; /// # Example /// /// ``` -/// use poem::{handler, route, EndpointExt}; +/// use poem::{handler, RouteMethod, route, EndpointExt}; /// use poem::web::{Json, Data}; /// use poem::middleware::AddData; /// use async_graphql_poem::GraphQLRequest; @@ -29,17 +29,20 @@ use tokio_util::compat::TokioAsyncReadCompatExt; /// /// type MySchema = Schema; /// -/// #[handler(method = "get")] +/// #[handler] /// async fn index(req: GraphQLRequest, schema: Data<&MySchema>) -> Json { /// Json(schema.execute(req.0).await) /// } /// -/// let app = route().at("/", index.with(AddData::new(Schema::new(Query, EmptyMutation, EmptySubscription)))); +/// let schema = Schema::new(Query, EmptyMutation, EmptySubscription); +/// let app = route().at("/", RouteMethod::new().post(index.with(AddData::new(schema)))); /// ``` 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 { Ok(GraphQLRequest( GraphQLBatchRequest::from_request(req, body) @@ -56,6 +59,8 @@ 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 { if req.method() == Method::GET { let req = Query::from_request(req, body) diff --git a/integrations/poem/src/query.rs b/integrations/poem/src/query.rs index 223ce4d4..1b5d1d5e 100644 --- a/integrations/poem/src/query.rs +++ b/integrations/poem/src/query.rs @@ -9,7 +9,7 @@ use crate::GraphQLBatchRequest; /// # Example /// /// ``` -/// use poem::route; +/// use poem::{route, RouteMethod}; /// use async_graphql_poem::GraphQL; /// use async_graphql::{EmptyMutation, EmptySubscription, Object, Schema}; /// @@ -24,7 +24,8 @@ use crate::GraphQLBatchRequest; /// /// type MySchema = Schema; /// -/// let app = route().at("/", GraphQL::new(Schema::new(Query, EmptyMutation, EmptySubscription))); +/// let schema = Schema::new(Query, EmptyMutation, EmptySubscription); +/// let app = route().at("/", RouteMethod::new().post(GraphQL::new(schema))); /// ``` pub struct GraphQL { schema: Schema, diff --git a/integrations/poem/src/subscription.rs b/integrations/poem/src/subscription.rs index 10e625c3..ed7a73ec 100644 --- a/integrations/poem/src/subscription.rs +++ b/integrations/poem/src/subscription.rs @@ -12,7 +12,7 @@ use poem::{http, Endpoint, FromRequest, IntoResponse, Request, Response, Result} /// # Example /// /// ``` -/// use poem::route; +/// use poem::{route, RouteMethod}; /// use async_graphql_poem::GraphQLSubscription; /// use async_graphql::{EmptyMutation, Object, Schema, Subscription}; /// use futures_util::{Stream, stream}; @@ -37,7 +37,8 @@ use poem::{http, Endpoint, FromRequest, IntoResponse, Request, Response, Result} /// /// type MySchema = Schema; /// -/// let app = route().at("/ws", GraphQLSubscription::new(Schema::new(Query, EmptyMutation, Subscription))); +/// let schema = Schema::new(Query, EmptyMutation, Subscription); +/// let app = route().at("/ws", RouteMethod::new().get(GraphQLSubscription::new(schema))); /// ``` pub struct GraphQLSubscription { schema: Schema,