MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / classify_post

Function classify_post

crates/openshell-supervisor-network/src/l7/graphql.rs:120–141  ·  view source on GitHub ↗
(body: &[u8])

Source from the content-addressed store, hash-verified

118}
119
120fn classify_post(body: &[u8]) -> std::result::Result<Vec<GraphqlOperationInfo>, String> {
121 if body.is_empty() {
122 return Err("GraphQL POST body is empty".to_string());
123 }
124 let value: Value = serde_json::from_slice(body)
125 .map_err(|err| format!("GraphQL request body is not valid JSON: {err}"))?;
126
127 match value {
128 Value::Array(items) => {
129 if items.is_empty() {
130 return Err("GraphQL batch request is empty".to_string());
131 }
132 let mut operations = Vec::new();
133 for item in items {
134 operations.extend(classify_json_envelope(&item)?);
135 }
136 Ok(operations)
137 }
138 Value::Object(_) => classify_json_envelope(&value),
139 _ => Err("GraphQL JSON envelope must be an object or array".to_string()),
140 }
141}
142
143fn classify_json_envelope(value: &Value) -> std::result::Result<Vec<GraphqlOperationInfo>, String> {
144 let obj = value

Callers 1

classify_request_innerFunction · 0.85

Calls 2

classify_json_envelopeFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected