Function kubos_app::query[][src]

pub fn query(
    config: ServiceConfig,
    query: &str,
    timeout: Option<Duration>
) -> Result<Value, Error>

Execute a GraphQL query against a running KubOS Service using UDP.

Returns the parsed JSON result as a serde_json::Value on success

Arguments

Examples

use kubos_app::*;
use std::time::Duration;

let request = r#"{
        ping
    }"#;

let result = query(ServiceConfig::new_from_path("radio-service", "/home/kubos/config.toml".to_owned()), request, Some(Duration::from_secs(1)))?;

let data = result.get("ping").unwrap().as_str();

assert_eq!(data, Some("pong"));
use kubos_app::*;
use std::time::Duration;

let request = r#"{
        power
    }"#;

let result = query(ServiceConfig::new("antenna-service"), request, Some(Duration::from_secs(1)))?;

let data = result.get("power").unwrap().as_str();

assert_eq!(data, Some("ON"));