MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / execute_read_only

Method execute_read_only

graphlite/src/catalog/providers/schema.rs:685–747  ·  view source on GitHub ↗
(&self, op: CatalogOperation)

Source from the content-addressed store, hash-verified

683 }
684
685 fn execute_read_only(&self, op: CatalogOperation) -> CatalogResult<CatalogResponse> {
686 // Handle read-only operations by delegating to the main execute method
687 // Since SchemaCatalog operations don't mutate during queries, this is safe
688 match op {
689 CatalogOperation::Query { query_type, params } => {
690 match query_type {
691 QueryType::List => {
692 let schemas: Vec<_> = self.schemas.values().collect();
693 let results = serde_json::to_value(schemas)?;
694 Ok(CatalogResponse::Query { results })
695 }
696 QueryType::Get => {
697 let schema_name =
698 params.get("name").and_then(|v| v.as_str()).ok_or_else(|| {
699 CatalogError::InvalidParameters("Schema name required".to_string())
700 })?;
701
702 if let Some(schema) = self.schemas.get(schema_name) {
703 let results = serde_json::to_value(schema)?;
704 Ok(CatalogResponse::Query { results })
705 } else {
706 Err(CatalogError::EntityNotFound(format!(
707 "Schema '{}' not found",
708 schema_name
709 )))
710 }
711 }
712 QueryType::GetDefault => {
713 if let Some(default_name) = &self.default_schema {
714 if let Some(schema) = self.schemas.get(default_name) {
715 let results = serde_json::to_value(schema)?;
716 Ok(CatalogResponse::Query { results })
717 } else {
718 Err(CatalogError::EntityNotFound(
719 "Default schema not found".to_string(),
720 ))
721 }
722 } else {
723 Err(CatalogError::EntityNotFound(
724 "No default schema set".to_string(),
725 ))
726 }
727 }
728 QueryType::Exists => {
729 let schema_name =
730 params.get("name").and_then(|v| v.as_str()).ok_or_else(|| {
731 CatalogError::InvalidParameters("Schema name required".to_string())
732 })?;
733
734 let exists = self.schemas.contains_key(schema_name);
735 Ok(CatalogResponse::Query {
736 results: serde_json::to_value(exists)?,
737 })
738 }
739 // Handle all other QueryType variants with NotSupported
740 _ => Ok(CatalogResponse::NotSupported),
741 }
742 }

Callers 1

query_read_onlyMethod · 0.45

Calls 3

getMethod · 0.45
as_strMethod · 0.45
contains_keyMethod · 0.45

Tested by

no test coverage detected