async-graphql/src/types/empty_mutation.rs

31 lines
873 B
Rust
Raw Normal View History

2020-03-02 00:24:49 +00:00
use crate::{
2020-03-03 11:15:18 +00:00
registry, ContextSelectionSet, ErrorWithPosition, GQLObject, GQLOutputValue, GQLType,
QueryError, Result,
2020-03-02 00:24:49 +00:00
};
use std::borrow::Cow;
pub struct GQLEmptyMutation;
impl GQLType for GQLEmptyMutation {
fn type_name() -> Cow<'static, str> {
Cow::Borrowed("EmptyMutation")
}
2020-03-03 03:48:00 +00:00
2020-03-03 11:15:18 +00:00
fn create_type_info(registry: &mut registry::Registry) -> String {
registry.create_type(&Self::type_name(), |_| registry::Type::Object {
name: "EmptyMutation",
description: None,
2020-03-03 03:48:00 +00:00
fields: Vec::new(),
})
}
2020-03-02 00:24:49 +00:00
}
#[async_trait::async_trait]
impl GQLOutputValue for GQLEmptyMutation {
async fn resolve(&self, ctx: &ContextSelectionSet<'_>) -> Result<serde_json::Value> {
anyhow::bail!(QueryError::NotConfiguredMutations.with_position(ctx.item.span.0));
}
}
impl GQLObject for GQLEmptyMutation {}