[][src]Struct warpgrapher::client::WarpgrapherClient

pub struct WarpgrapherClient { /* fields omitted */ }

A Warpgrapher GraphQL client

The WarpgrapherClient provides a set of CRUD operations that will automatically generate GraphQL queries that conform to the wargrapher API

Examples

use std::env::var_os;
use warpgrapher::WarpgrapherClient;

let mut client = WarpgrapherClient::new("http://localhost:5000/graphql");

Methods

impl WarpgrapherClient[src]

pub fn new(endpoint: &str) -> WarpgrapherClient[src]

Takes an endpoint string and creates a new WarpgrapherClient.

Examples

use std::env::var_os;
use warpgrapher::WarpgrapherClient;

let mut client = WarpgrapherClient::new("http://localhost:5000/graphql");

pub fn create_node(
    &mut self,
    type_name: &str,
    shape: &str,
    input: &Value
) -> Result<Value, Error>
[src]

Takes the name of a WarpgrapherType and executes a NodeCreate operation. Requires a query shape and the input of the node being created.

Examples

use serde_json::json;
use std::env::var_os;
use warpgrapher::WarpgrapherClient;

let mut client = WarpgrapherClient::new("http://localhost:5000/graphql");

let projects = client.create_node(
    "Project",
    "id name description",
    &json!({"name": "TodoApp", "description": "TODO list tracking application"}),
);

pub fn create_rel(
    &mut self,
    type_name: &str,
    rel_name: &str,
    shape: &str,
    match_input: &Value,
    create_input: &Value
) -> Result<Value, Error>
[src]

Takes the name of a WarpgrapherType and a relationship property on that types and executes a RelCreate operation. Requires also a query shape, an input to match the source node(s) for which the rel(s) will be created, and an input of the relationship being created.

Examples

use serde_json::json;
use std::env::var_os;
use warpgrapher::WarpgrapherClient;

let mut client = WarpgrapherClient::new("http:://localhost:5000/graphql");

let proj_issues = client.create_rel(
    "Project",
    "issues",
    "id props { since } src { id name } dst { id name }",
    &json!({"name": "ProjectName"}),
    &json!({"props": {"since": "2000"},
           "dst": {"Feature": {"NEW": {"name": "NewFeature"}}}})
);

pub fn delete_node(
    &mut self,
    type_name: &str,
    match_input: Option<&Value>,
    delete_input: Option<&Value>
) -> Result<Value, Error>
[src]

Takes the name of a WarpgrapherType and executes a Delete operation. Takes two optional inputs. The first selects the node(s) for deletion.
The second contains options for forcing the delete, meaning deleting node along with any relationships to and from it -- without the force flag, deleting a node with relationships will fail. Also contains options for deleting additional nodes and rels connected to the target node. Returns the number of nodes of the WarpgrapherType deleted.

Examples

use std::env::var_os;
use warpgrapher::WarpgrapherClient;
use serde_json::json;

let mut client = WarpgrapherClient::new("http://localhost:5000/graphql");

let projects = client.delete_node(
    "Project",
    Some(&json!({"name": "MJOLNIR"})),
    None);

pub fn delete_rel(
    &mut self,
    type_name: &str,
    rel_name: &str,
    match_input: Option<&Value>,
    src_input: Option<&Value>,
    dst_input: Option<&Value>
) -> Result<Value, Error>
[src]

Takes the name of a WarpgrapherType and a relationship property on that types and executes a RelDelete operation. Takes three optional inputs. The first selects the relationship(s) for deletion. The second and third, if present, request the deletion of the src and dst nodes associated with the relationship, and potentially additional nodes and rels as well. Returns the number of matched relationships deleted.

Examples

use serde_json::json;
use std::env::var_os;
use warpgrapher::WarpgrapherClient;

let mut client = WarpgrapherClient::new("http:://localhost:5000/graphql");

let proj_issues = client.delete_rel("Project", "issues",
    Some(&json!({"props": {"since": "2000"}})),
    None,
    Some(&json!({"Bug": {"force": true}}))
);

pub fn read_node(
    &mut self,
    type_name: &str,
    shape: &str,
    input: Option<&Value>
) -> Result<Value, Error>
[src]

Takes the name of a WarpgrapherType and executes a Read operation. Requires a query shape and takes an optional input which filters the results.

Examples

use std::env::var_os;
use warpgrapher::WarpgrapherClient;

let mut client = WarpgrapherClient::new("http://localhost:5000/graphql");

let projects = client.read_node("Project", "id name description", None);

pub fn read_rel(
    &mut self,
    type_name: &str,
    rel_name: &str,
    shape: &str,
    input: Option<&Value>
) -> Result<Value, Error>
[src]

Takes the name of a WarpgrapherType and a relationship property on that types and executes a read operation. Also takes an option input with match criteria for selecting the relationship to read.

Examples

use serde_json::json;
use std::env::var_os;
use warpgrapher::WarpgrapherClient;

let mut client = WarpgrapherClient::new("http:://localhost:5000/graphql");

let proj_issues = client.read_rel("Project", "issues",
    "id props { since }",
    Some(&json!({"props": {"since": "2000"}}))
);

pub fn update_node(
    &mut self,
    type_name: &str,
    shape: &str,
    match_input: Option<&Value>,
    update_input: &Value
) -> Result<Value, Error>
[src]

Takes the name of a WarpgrapherType and executes an Update operation. Requires a query shape, an optional match component of the input, and a mandatory update component of the input.

Examples

use serde_json::json;
use std::env::var_os;
use warpgrapher::WarpgrapherClient;

let mut client = WarpgrapherClient::new("http://localhost:5000/graphql");

let projects = client.update_node(
    "Project",
    "id name status",
    Some(&json!({"name": "TodoApp"})),
    &json!({"status": "ACTIVE"}),
);

pub fn update_rel(
    &mut self,
    type_name: &str,
    rel_name: &str,
    shape: &str,
    match_input: Option<&Value>,
    update_input: &Value
) -> Result<Value, Error>
[src]

Takes the name of a WarpgrapherType and a relationship property on that types and executes a RelUpdate operation. Requires a shape of result to be returned. Takes an optional input that selects the relationship for update, and a mandatory input describing the update to be performed.
Returns the number of matched relationships deleted.

Examples

use serde_json::json;
use std::env::var_os;
use warpgrapher::WarpgrapherClient;

let mut client = WarpgrapherClient::new("http:://localhost:5000/graphql");

let proj_issues = client.update_rel("Project", "issues",
    "id props {since} src {id name} dst {id name}",
    Some(&json!({"props": {"since": "2000"}})),
    &json!({"props": {"since": "2010"}})
);

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> Erased for T

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

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

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<T> Typeable for T where
    T: Any

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