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