Struct async_graphql::dynamic::Scalar
source · pub struct Scalar { /* private fields */ }
Available on crate feature
dynamic-schema
only.Expand description
A GraphQL scalar type
Examples
use async_graphql::{dynamic::*, value, Value};
let my_scalar = Scalar::new("MyScalar");
let query = Object::new("Query").field(Field::new("value", my_scalar.type_ref(), |ctx| {
FieldFuture::new(async move { Ok(Some(Value::from("abc"))) })
}));
let schema = Schema::build(query.type_name(), None, None)
.register(my_scalar)
.register(query)
.finish()?;
assert_eq!(
schema
.execute("{ value }")
.await
.into_result()
.unwrap()
.data,
value!({ "value": "abc" })
);
Implementations
sourceimpl Scalar
impl Scalar
sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Set the description
sourcepub fn specified_by_url(self, specified_by_url: impl Into<String>) -> Self
pub fn specified_by_url(self, specified_by_url: impl Into<String>) -> Self
Set the specified by url
sourcepub fn type_ref(&self) -> NamedTypeRefBuilder
pub fn type_ref(&self) -> NamedTypeRefBuilder
Returns the type reference
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Scalar
impl Send for Scalar
impl Sync for Scalar
impl Unpin for Scalar
impl UnwindSafe for Scalar
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more