|
| 1 | +use std::collections::HashMap; |
| 2 | + |
| 3 | +use bytes::Bytes; |
| 4 | +use hive_router_query_planner::ast::operation::SubgraphFetchOperation; |
| 5 | +use ntex::web::HttpRequest; |
| 6 | + |
| 7 | +use crate::{executors::dedupe::SharedResponse, response::{graphql_error::GraphQLError, value::Value}}; |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +pub struct OnSubgraphExecuteStartPayload<'exec> { |
| 12 | + pub router_http_request: &'exec HttpRequest, |
| 13 | + pub subgraph_name: &'exec str, |
| 14 | + // The node that initiates this subgraph execution |
| 15 | + pub execution_request: &'exec mut SubgraphExecutionRequest<'exec>, |
| 16 | + // This will be tricky to implement with the current structure, |
| 17 | + // but I'm sure we'll figure it out |
| 18 | + pub response: &'exec mut Option<SubgraphResponse<'exec>>, |
| 19 | +} |
| 20 | + |
| 21 | +pub struct SubgraphExecutionRequest<'exec> { |
| 22 | + pub query: &'exec str, |
| 23 | + // We can add the original operation here too |
| 24 | + pub operation: &'exec SubgraphFetchOperation, |
| 25 | + |
| 26 | + pub dedupe: bool, |
| 27 | + pub operation_name: Option<&'exec str>, |
| 28 | + pub variables: Option<HashMap<&'exec str, &'exec sonic_rs::Value>>, |
| 29 | + pub extensions: Option<HashMap<String, sonic_rs::Value>>, |
| 30 | + pub representations: Option<Vec<u8>>, |
| 31 | +} |
| 32 | + |
| 33 | +pub struct SubgraphResponse<'exec> { |
| 34 | + pub data: Value<'exec>, |
| 35 | + pub errors: Option<Vec<GraphQLError>>, |
| 36 | + pub extensions: Option<HashMap<String, Value<'exec>>>, |
| 37 | +} |
| 38 | + |
| 39 | +pub struct OnSubgraphExecuteEndPayload<'exec> { |
| 40 | + pub router_http_request: &'exec HttpRequest, |
| 41 | + pub subgraph_name: &'exec str, |
| 42 | + // The node that initiates this subgraph execution |
| 43 | + pub execution_request: &'exec SubgraphExecutionRequest<'exec>, |
| 44 | + // This will be tricky to implement with the current structure, |
| 45 | + // but I'm sure we'll figure it out |
| 46 | + pub response: &'exec SubgraphResponse<'exec>, |
| 47 | +} |
0 commit comments