mongo_graphql/
executor.rs1use async_graphql::dynamic::Schema;
2use async_graphql::{Data, Request, Variables};
3
4use crate::error::GraphQLError;
5
6pub async fn execute(
8 schema: &Schema,
9 query: &str,
10 variables: Variables,
11 data: Option<Data>,
12) -> Result<serde_json::Value, GraphQLError> {
13 let mut request = Request::new(query).variables(variables);
14 if let Some(data) = data {
15 request.data = data;
16 }
17 let response = schema.execute(request).await;
18 serde_json::to_value(response)
19 .map_err(|e| GraphQLError::Internal(format!("Serialization error: {}", e)))
20}