reactive_graph_graphql_schema/query/json_schema/
instances.rs

1use async_graphql::Context;
2use async_graphql::Object;
3use async_graphql::Result;
4use reactive_graph_instance_system_json_schema::schema_entity_instances;
5use reactive_graph_instance_system_json_schema::schema_flow_instances;
6use reactive_graph_instance_system_json_schema::schema_relation_instances;
7use serde_json::Value;
8
9#[derive(Default)]
10pub struct JsonSchemaInstanceSystem;
11
12/// Get the JSON schema of the instance system (entity instances, relation instances or flow instances).
13#[Object]
14impl JsonSchemaInstanceSystem {
15    /// Returns the JSON schema for entity instances.
16    async fn entities(&self, _context: &Context<'_>) -> Result<Value> {
17        Ok(schema_entity_instances().to_value())
18    }
19
20    /// Returns the JSON schema for relation instances.
21    async fn relations(&self, _context: &Context<'_>) -> Result<Value> {
22        Ok(schema_relation_instances().to_value())
23    }
24
25    /// Returns the JSON schema for flow instances.
26    async fn flows(&self, _context: &Context<'_>) -> Result<Value> {
27        Ok(schema_flow_instances().to_value())
28    }
29}