Implements Default for Schema.
This commit is contained in:
parent
ca5f91aee4
commit
6a38057a22
|
@ -153,6 +153,21 @@ impl<Query, Mutation, Subscription> Clone for Schema<Query, Mutation, Subscripti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<Query, Mutation, Subscription> Default for Schema<Query, Mutation, Subscription>
|
||||||
|
where
|
||||||
|
Query: Default + ObjectType + Send + Sync + 'static,
|
||||||
|
Mutation: Default + ObjectType + Send + Sync + 'static,
|
||||||
|
Subscription: Default + SubscriptionType + Send + Sync + 'static,
|
||||||
|
{
|
||||||
|
fn default() -> Self {
|
||||||
|
Schema::new(
|
||||||
|
Query::default(),
|
||||||
|
Mutation::default(),
|
||||||
|
Subscription::default(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<Query, Mutation, Subscription> Deref for Schema<Query, Mutation, Subscription>
|
impl<Query, Mutation, Subscription> Deref for Schema<Query, Mutation, Subscription>
|
||||||
where
|
where
|
||||||
Query: ObjectType + Send + Sync + 'static,
|
Query: ObjectType + Send + Sync + 'static,
|
||||||
|
|
|
@ -21,6 +21,7 @@ use std::borrow::Cow;
|
||||||
///
|
///
|
||||||
/// let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
|
/// let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
|
||||||
/// ```
|
/// ```
|
||||||
|
#[derive(Default, Copy, Clone)]
|
||||||
pub struct EmptyMutation;
|
pub struct EmptyMutation;
|
||||||
|
|
||||||
impl Type for EmptyMutation {
|
impl Type for EmptyMutation {
|
||||||
|
|
|
@ -7,6 +7,7 @@ use std::pin::Pin;
|
||||||
/// Empty subscription
|
/// Empty subscription
|
||||||
///
|
///
|
||||||
/// Only the parameters used to construct the Schema, representing an unconfigured subscription.
|
/// Only the parameters used to construct the Schema, representing an unconfigured subscription.
|
||||||
|
#[derive(Default, Copy, Clone)]
|
||||||
pub struct EmptySubscription;
|
pub struct EmptySubscription;
|
||||||
|
|
||||||
impl Type for EmptySubscription {
|
impl Type for EmptySubscription {
|
||||||
|
|
11
tests/schema.rs
Normal file
11
tests/schema.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
use async_graphql::*;
|
||||||
|
|
||||||
|
#[async_std::test]
|
||||||
|
pub async fn test_schema_default() {
|
||||||
|
#[derive(GQLSimpleObject, Default)]
|
||||||
|
struct Query;
|
||||||
|
|
||||||
|
type MySchema = Schema<Query, EmptyMutation, EmptySubscription>;
|
||||||
|
|
||||||
|
let _schema = MySchema::default();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user