[][src]Struct warpgrapher::engine::config::Relationship

pub struct Relationship { /* fields omitted */ }

Configuration item for a relationship on a GraphQL type

Examples


let r = Relationship::new(
    "teams".to_string(),
    true,
    vec!["User".to_string()],
    vec![],  
    EndpointsFilter::all(),
    None
);

Implementations

impl Relationship[src]

pub fn new(
    name: String,
    list: bool,
    nodes: Vec<String>,
    props: Vec<Property>,
    endpoints: EndpointsFilter,
    resolver: Option<String>
) -> Relationship
[src]

Creates a new Relationship struct.

Arguments

  • a String for the name of the relationship
  • a boolean that, if true, indicates that the property is a list, and if false, that the relationship is to a single node
  • a list of possible destination node types for the relationship. A single element in the list indicates that this is a single-type relationship, whereas more than one element indicates a multi-type relationship.
  • an EndpointsFilter struct indicating which of the standard operations (create, read, update, and delete) should be generated for this relationship
  • an optional string providing the name of a resolver, if the relationship is a dynamic relationship with a custom resolver

Examples


let r = Relationship::new("name".to_string(), false, vec!["User".to_string()], vec![],
    EndpointsFilter::all(), None);

pub fn endpoints(&self) -> &EndpointsFilter[src]

Returns the EndpointsFilter struct that indicates which of the four basic Create, Read, Update, and Delete (CRUD) operations Warpgrapher should auto-generate for this relationship.

Examples


let r = Relationship::new("name".to_string(), false, vec!["User".to_string()], vec![],
    EndpointsFilter::all(), None);

assert_eq!(&EndpointsFilter::all(), r.endpoints());

pub fn list(&self) -> bool[src]

Returns true if the relationship is a list, indicating a one-to-many (or many-to-many) relationship. Returns false if the node can only have one relationship of this type.

Examples


let r = Relationship::new("name".to_string(), true, vec!["User".to_string()], vec![],
    EndpointsFilter::all(), None);

assert!(r.list());

pub fn name(&self) -> &str[src]

Returns the name of the relationship

Examples


let r = Relationship::new("RelName".to_string(), true, vec!["User".to_string()], vec![],
    EndpointsFilter::all(), None);

assert_eq!("RelName", r.name());

pub fn nodes(&self) -> Iter<'_, String>[src]

Returns an iterator over the names of the Warpgrapher Type definitions that are possible destination nodes for this relationship.

Examples


let r = Relationship::new("RelName".to_string(), true, vec!["User".to_string()], vec![],
    EndpointsFilter::all(), None);

assert_eq!(1, r.nodes().count());
assert_eq!("User", r.nodes().next().expect("Expected an element"));

pub fn props_as_slice(&self) -> &[Property][src]

Returns a slice of Property references for properties associated with the relationship.

Examples


let r = Relationship::new("RelName".to_string(), true, vec!["User".to_string()], vec![],
    EndpointsFilter::all(), None);

assert_eq!(0, r.props_as_slice().len())

pub fn resolver(&self) -> Option<&String>[src]

Returns an option for a string containing the name of a custom resolver, if this relationship is resolved by a custom resolver instead of an auto-generated read resolver.

Examples


let r = Relationship::new("RelName".to_string(), true, vec!["User".to_string()], vec![],
    EndpointsFilter::all(), None);

assert!(r.resolver().is_none())

Trait Implementations

impl Clone for Relationship[src]

impl Debug for Relationship[src]

impl<'de> Deserialize<'de> for Relationship[src]

impl Eq for Relationship[src]

impl Hash for Relationship[src]

impl Ord for Relationship[src]

impl PartialEq<Relationship> for Relationship[src]

impl PartialOrd<Relationship> for Relationship[src]

impl Serialize for Relationship[src]

impl StructuralEq for Relationship[src]

impl StructuralPartialEq for Relationship[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,