GraphDB wasmCloud Actor Interface
This crate provides an abstraction over the wasmcloud:graphdb
contract. This
allows actors to interact with a graph database, such as RedisGraph or Neo4j.
Example:
```rust use serdejson::json; extern crate wapcguest as guest; use wasmcloudactorgraphdb as graph; use graph::*; use wasmcloudactorhttp_server as http;
use guest::prelude::*;
pub fn wapcinit() { http::Handlers::registerhandlerequest(handlehttprequest); wasmcloudactorcore::Handlers::registerhealth_request(health); }
fn handlehttprequest(: http::Request) -> HandlerResulthttp::Response {
// Replace query_db
with graph::default().query_graph()
let (name, birthyear): (String, u32) = querydb(
"MotoGP".tostring(),
"MATCH (r:Rider)-[:rides]->(t:Team) WHERE t.name = 'Yamaha' RETURN r.name, r.birthyear"
.tostring(),
)?;
assert_eq!(name, "Alice Rider".to_string());
assert_eq!(birth_year, 1985);
let result = json!({
"name": name,
"birth_year": birth_year
});
Ok(http::Response::json(result, 200, "OK"))
}
fn health(: wasmcloudactorcore::HealthCheckRequest) -> HandlerResult
}
```