(
query: Option<&str>,
operation_name: Option<&str>,
extensions: Option<&Value>,
persisted_id: Option<String>,
)
| 158 | } |
| 159 | |
| 160 | fn classify_envelope( |
| 161 | query: Option<&str>, |
| 162 | operation_name: Option<&str>, |
| 163 | extensions: Option<&Value>, |
| 164 | persisted_id: Option<String>, |
| 165 | ) -> std::result::Result<Vec<GraphqlOperationInfo>, String> { |
| 166 | let persisted_hash = persisted_query_hash(extensions); |
| 167 | let query = query.filter(|q| !q.trim().is_empty()); |
| 168 | |
| 169 | if let Some(query) = query { |
| 170 | let mut operation = classify_document(query, operation_name)?; |
| 171 | if let Some(hash) = persisted_hash { |
| 172 | operation.persisted_query = true; |
| 173 | operation.persisted_query_hash = Some(hash); |
| 174 | } |
| 175 | if let Some(id) = persisted_id { |
| 176 | operation.persisted_query = true; |
| 177 | operation.persisted_query_id = Some(id); |
| 178 | } |
| 179 | return Ok(vec![operation]); |
| 180 | } |
| 181 | |
| 182 | if persisted_hash.is_some() || persisted_id.is_some() { |
| 183 | return Ok(vec![GraphqlOperationInfo { |
| 184 | operation_type: String::new(), |
| 185 | operation_name: operation_name.map(ToString::to_string), |
| 186 | fields: Vec::new(), |
| 187 | persisted_query: true, |
| 188 | persisted_query_hash: persisted_hash, |
| 189 | persisted_query_id: persisted_id, |
| 190 | }]); |
| 191 | } |
| 192 | |
| 193 | Err("GraphQL request has no query document or persisted query identifier".to_string()) |
| 194 | } |
| 195 | |
| 196 | fn classify_document( |
| 197 | query: &str, |
no test coverage detected