Merge pull request #213 from TsumiNa/update_async_graphql_tide
Update async_graphql_tide to support tide-0.12.0
This commit is contained in:
commit
9e3f2debf3
@ -14,12 +14,12 @@ categories = ["network-programming", "asynchronous"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-graphql = { path = "..", version = "1.16.1" }
|
async-graphql = { path = "..", version = "1.16.1" }
|
||||||
tide = "0.11.0"
|
tide = "0.12.0"
|
||||||
async-trait = "0.1.30"
|
async-trait = "0.1.36"
|
||||||
serde_json = "1.0.51"
|
serde_json = "1.0.56"
|
||||||
futures = "0.3.4"
|
futures = "0.3.5"
|
||||||
async-std = "1.6.0"
|
async-std = "1.6.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
smol = { version = "0.1.10", features = ["tokio02"] }
|
smol = { version = "0.1.18", features = ["tokio02"] }
|
||||||
reqwest = "0.10.4"
|
reqwest = "0.10.6"
|
||||||
|
@ -62,7 +62,7 @@ where
|
|||||||
Query: ObjectType + Send + Sync + 'static,
|
Query: ObjectType + Send + Sync + 'static,
|
||||||
Mutation: ObjectType + Send + Sync + 'static,
|
Mutation: ObjectType + Send + Sync + 'static,
|
||||||
Subscription: SubscriptionType + Send + Sync + 'static,
|
Subscription: SubscriptionType + Send + Sync + 'static,
|
||||||
TideState: Send + Sync + 'static,
|
TideState: Clone + Send + Sync + 'static,
|
||||||
F: Fn(QueryBuilder) -> QueryBuilder + Send,
|
F: Fn(QueryBuilder) -> QueryBuilder + Send,
|
||||||
{
|
{
|
||||||
graphql_opts(req, schema, query_builder_configuration, Default::default()).await
|
graphql_opts(req, schema, query_builder_configuration, Default::default()).await
|
||||||
@ -79,7 +79,7 @@ where
|
|||||||
Query: ObjectType + Send + Sync + 'static,
|
Query: ObjectType + Send + Sync + 'static,
|
||||||
Mutation: ObjectType + Send + Sync + 'static,
|
Mutation: ObjectType + Send + Sync + 'static,
|
||||||
Subscription: SubscriptionType + Send + Sync + 'static,
|
Subscription: SubscriptionType + Send + Sync + 'static,
|
||||||
TideState: Send + Sync + 'static,
|
TideState: Clone + Send + Sync + 'static,
|
||||||
F: Fn(QueryBuilder) -> QueryBuilder + Send,
|
F: Fn(QueryBuilder) -> QueryBuilder + Send,
|
||||||
{
|
{
|
||||||
let query_builder = req.body_graphql_opts(opts).await?;
|
let query_builder = req.body_graphql_opts(opts).await?;
|
||||||
@ -93,7 +93,7 @@ where
|
|||||||
/// Tide request extension
|
/// Tide request extension
|
||||||
///
|
///
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait RequestExt<State: Send + Sync + 'static>: Sized {
|
pub trait RequestExt<State: Clone + Send + Sync + 'static>: Sized {
|
||||||
/// Convert a query to `async_graphql::QueryBuilder`.
|
/// Convert a query to `async_graphql::QueryBuilder`.
|
||||||
async fn body_graphql(self) -> tide::Result<QueryBuilder> {
|
async fn body_graphql(self) -> tide::Result<QueryBuilder> {
|
||||||
self.body_graphql_opts(Default::default()).await
|
self.body_graphql_opts(Default::default()).await
|
||||||
@ -104,7 +104,7 @@ pub trait RequestExt<State: Send + Sync + 'static>: Sized {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<State: Send + Sync + 'static> RequestExt<State> for Request<State> {
|
impl<State: Clone + Send + Sync + 'static> RequestExt<State> for Request<State> {
|
||||||
async fn body_graphql_opts(self, opts: IntoQueryBuilderOpts) -> tide::Result<QueryBuilder> {
|
async fn body_graphql_opts(self, opts: IntoQueryBuilderOpts) -> tide::Result<QueryBuilder> {
|
||||||
if self.method() == Method::Get {
|
if self.method() == Method::Get {
|
||||||
let gql_request: GQLRequest = self.query::<GQLRequest>()?;
|
let gql_request: GQLRequest = self.query::<GQLRequest>()?;
|
||||||
|
@ -35,7 +35,7 @@ fn quickstart() -> Result<()> {
|
|||||||
|
|
||||||
let mut app = tide::new();
|
let mut app = tide::new();
|
||||||
app.at("/").post(graphql).get(graphql);
|
app.at("/").post(graphql).get(graphql);
|
||||||
app.listen(&listen_addr).await?;
|
app.listen(listen_addr).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
@ -109,6 +109,7 @@ fn hello() -> Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
struct AppState {
|
struct AppState {
|
||||||
schema: Schema<QueryRoot, EmptyMutation, EmptySubscription>,
|
schema: Schema<QueryRoot, EmptyMutation, EmptySubscription>,
|
||||||
}
|
}
|
||||||
@ -131,7 +132,7 @@ fn hello() -> Result<()> {
|
|||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
});
|
});
|
||||||
app.listen(&listen_addr).await?;
|
app.listen(listen_addr).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
@ -229,7 +230,7 @@ fn upload() -> Result<()> {
|
|||||||
let schema = Schema::build(QueryRoot, MutationRoot, EmptySubscription).finish();
|
let schema = Schema::build(QueryRoot, MutationRoot, EmptySubscription).finish();
|
||||||
async_graphql_tide::graphql(req, schema, |query_builder| query_builder).await
|
async_graphql_tide::graphql(req, schema, |query_builder| query_builder).await
|
||||||
});
|
});
|
||||||
app.listen(&listen_addr).await?;
|
app.listen(listen_addr).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user