hyperlane_plugin_graphql/
struct.rs1use super::*;
2
3#[derive(Clone, Debug, Eq, Getter, PartialEq)]
5pub struct FieldSelection {
6 pub(crate) alias: Option<String>,
8 pub(crate) name: String,
10 pub(crate) arguments: BTreeMap<String, Value>,
12 pub(crate) sub_fields: Vec<FieldSelection>,
14}
15
16#[derive(Clone, Debug, Eq, Getter, PartialEq)]
18pub struct ParsedOperation {
19 #[get(type(copy))]
21 pub(crate) kind: OperationKind,
22 pub(crate) name: Option<String>,
24 pub(crate) selections: Vec<FieldSelection>,
26}
27
28#[derive(Clone, Debug, Getter)]
30pub struct GraphqlFieldArgs {
31 pub(crate) arguments: BTreeMap<String, Value>,
33 pub(crate) variables: Map<String, Value>,
35}
36
37#[derive(Clone, Debug, Deserialize, Getter, Serialize)]
39pub struct GraphqlRequest {
40 pub(crate) query: String,
42 #[serde(rename = "operationName", default)]
44 pub(crate) operation_name: Option<String>,
45 #[serde(default)]
47 pub(crate) variables: Map<String, Value>,
48}
49
50#[derive(Clone, Debug, Deserialize, Eq, Getter, PartialEq, Serialize)]
52pub struct GraphqlError {
53 pub(crate) message: String,
55}
56
57#[derive(Clone, Debug, Deserialize, Eq, Getter, PartialEq, Serialize)]
59pub struct GraphqlResponse {
60 #[serde(skip_serializing_if = "Option::is_none")]
62 pub(crate) data: Option<Value>,
63 #[serde(default, skip_serializing_if = "Vec::is_empty")]
65 pub(crate) errors: Vec<GraphqlError>,
66}
67
68#[derive(Clone, Data, Debug, Eq, PartialEq)]
70pub struct GraphqlConfig {
71 pub(crate) endpoint: String,
73 #[get(type(copy))]
75 pub(crate) max_depth: usize,
76 #[get(type(copy))]
78 pub(crate) max_fields: usize,
79 #[get(type(copy))]
81 pub(crate) max_query_bytes: usize,
82 #[get(type(copy))]
84 pub(crate) allow_get: bool,
85}
86
87pub struct FnGraphqlResolver<F> {
89 pub(crate) func: F,
91}
92
93pub struct GraphqlPlugin {
95 pub(crate) config: GraphqlConfig,
97 pub(crate) queries: HashMapXxHash3_64<String, Arc<dyn GraphqlResolver>>,
99 pub(crate) mutations: HashMapXxHash3_64<String, Arc<dyn GraphqlResolver>>,
101}
102
103#[derive(Clone, Copy, Debug, Default)]
105#[hyperlane::request_middleware(-62)]
106pub struct GraphqlHook;