pub struct Type { /* private fields */ }
Expand description
Configuration item for a GraphQL type. In back-end storage, the type is recorded in a label attached to the graph node.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(),
true, false, None, None),
Property::new("role".to_string(), UsesFilter::all(), "String".to_string(),
true, false, None, None)),
vec!(),
EndpointsFilter::all()
);
Implementations
pub fn new(
name: String,
props: Vec<Property>,
rels: Vec<Relationship>,
endpoints: EndpointsFilter
) -> Type
pub fn new(
name: String,
props: Vec<Property>,
rels: Vec<Relationship>,
endpoints: EndpointsFilter
) -> Type
Creates a new Type struct.
Arguments
- name - the name of the type, which will be recorded as the label on a node in the graph back-end
- props - a vector of
Property
structs describing the properties on the node - rels - a vector of
Relationship
structs describing the outgoing relationships from this node type - endpoints - an
EndpointsFilter
struct describing which CRUD operations should be generated automatically for this node type.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(),
true, false, None, None),
Property::new("role".to_string(), UsesFilter::all(), "String".to_string(),
true, false, None, None)),
vec!(),
EndpointsFilter::all()
);
Returns the name of the type. This type name is used as the label on nodes of this type in the graph database storage back-end.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(), true, false, None, None),
Property::new("role".to_string(), UsesFilter::all(), "String".to_string(), true, false, None, None)),
vec!(),
EndpointsFilter::all()
);
assert_eq!("User", t.name());
Returns the EndpointsFilter
struct associate with this type, determining which CRUD
operations should be auto-generated for this node type.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(), true, false, None, None),
Property::new("role".to_string(), UsesFilter::all(), "String".to_string(), true, false, None, None)),
vec!(),
EndpointsFilter::all()
);
assert_eq!(&EndpointsFilter::all(), t.endpoints());
Returns an iterator over the Property
structs defining properties on this node type.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(),
true, false, None, None)), vec!(), EndpointsFilter::all());
assert_eq!("name", t.props().next().expect("Expected property").name());
Returns a slice of the Property
structs defining properties on this node type.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(), true, false, None, None)),
vec!(),
EndpointsFilter::all()
);
assert_eq!("name", t.props_as_slice()[0].name());
Returns an iterator over the Relationship
structs defining relationships originating
from this node type.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(), true,
false, None, None)),
vec!(Relationship::new("rel_name".to_string(), false, vec!("Role".to_string()), vec!(
Property::new("rel_prop".to_string(), UsesFilter::all(), "String".to_string(), true, false, None, None)
), EndpointsFilter::all(), None)),
EndpointsFilter::all()
);
assert_eq!("rel_name", t.rels().next().expect("Expected relationship").name());
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Creates a new Type struct from a yaml-formatted string.
Errors
Returns an Error
variant YamlDeserializationFailed
if the yaml-formatted
string is improperly formatted.
Examples
use warpgrapher::engine::config::{Type};
use std::convert::TryFrom;
let t = Type::try_from("
name: User
props:
- name: name
type: String
").unwrap();
Auto Trait Implementations
impl RefUnwindSafe for Type
impl UnwindSafe for Type
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more