async_graphql/dynamic/mod.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
//! Suppport for dynamic schema
//!
//! # Create a simple GraphQL schema
//!
//! ```
//! use async_graphql::{dynamic::*, value, Value};
//!
//! let query = Object::new("Query").field(Field::new("value", TypeRef::named_nn(TypeRef::INT), |ctx| {
//! FieldFuture::new(async move { Ok(Some(Value::from(100))) })
//! }));
//!
//! # tokio::runtime::Runtime::new().unwrap().block_on(async move {
//!
//! let schema = Schema::build(query.type_name(), None, None)
//! .register(query)
//! .finish()?;
//!
//! assert_eq!(
//! schema
//! .execute("{ value }")
//! .await
//! .into_result()
//! .unwrap()
//! .data,
//! value!({ "value": 100 })
//! );
//!
//! # Ok::<_, SchemaError>(())
//! # }).unwrap();
//! ```
#[macro_use]
mod macros;
mod base;
mod check;
mod r#enum;
mod error;
mod field;
mod input_object;
mod input_value;
mod interface;
mod object;
mod request;
mod resolve;
mod scalar;
mod schema;
mod subscription;
mod r#type;
mod type_ref;
mod union;
mod value_accessor;
pub use error::SchemaError;
pub use field::{Field, FieldFuture, FieldValue, ResolverContext};
pub use indexmap;
pub use input_object::InputObject;
pub use input_value::InputValue;
pub use interface::{Interface, InterfaceField};
pub use object::Object;
pub use r#enum::{Enum, EnumItem};
pub use r#type::Type;
pub use request::{DynamicRequest, DynamicRequestExt};
pub use scalar::Scalar;
pub use schema::{Schema, SchemaBuilder};
pub use subscription::{Subscription, SubscriptionField, SubscriptionFieldFuture};
pub use type_ref::TypeRef;
pub use union::Union;
pub use value_accessor::{ListAccessor, ObjectAccessor, ValueAccessor};