reactive_graph_runtime_graphql_schema/
instance_address.rs

1use async_graphql::InputObject;
2use serde::Deserialize;
3use serde::Serialize;
4
5use reactive_graph_remotes_model::DEFAULT_ENDPOINT_DYNAMIC_GRAPH;
6use reactive_graph_remotes_model::DEFAULT_ENDPOINT_GRAPHQL;
7use reactive_graph_remotes_model::DEFAULT_ENDPOINT_PLUGIN;
8use reactive_graph_remotes_model::DEFAULT_ENDPOINT_RUNTIME;
9use reactive_graph_remotes_model::DEFAULT_USER_AGENT;
10use reactive_graph_remotes_model::InstanceAddress;
11
12#[derive(Clone, Debug, Serialize, Deserialize, InputObject)]
13#[graphql(name = "InstanceAddress")]
14pub struct InstanceAddressDefinition {
15    /// The hostname.
16    pub hostname: String,
17
18    /// The port.
19    pub port: u16,
20
21    /// Secure endpoint.
22    pub secure: Option<bool>,
23
24    /// The user agent.
25    pub user_agent: Option<String>,
26
27    /// The relative URL of the GraphQL endpoint, by default "/graphql".
28    pub endpoint_graphql: Option<String>,
29
30    /// The relative URL of the dynamic graph endpoint, by default "/dynamic_graph".
31    pub endpoint_dynamic_graph: Option<String>,
32
33    /// The relative URL of the runtime endpoint, by default "/runtime/graphql".
34    pub endpoint_runtime: Option<String>,
35
36    /// The relative URL of the plugins endpoint, by default "/plugin/graphql".
37    pub endpoint_plugin: Option<String>,
38
39    /// The authentication token.
40    pub bearer: Option<String>,
41
42    /// Controls the use of certificate validation.
43    ///
44    /// Defaults to `false`.
45    ///
46    /// Warning: You should think very carefully before using this method. If
47    /// invalid certificates are trusted, *any* certificate for *any* site
48    /// will be trusted for use. This includes expired certificates. This
49    /// introduces significant vulnerabilities, and should only be used
50    /// as a last resort.
51    danger_accept_invalid_certs: Option<bool>,
52
53    /// Controls the use of hostname verification.
54    ///
55    /// Defaults to `false`.
56    ///
57    /// Warning: You should think very carefully before you use this method. If
58    /// hostname verification is not used, any valid certificate for any
59    /// site will be trusted for use from any other. This introduces a
60    /// significant vulnerability to man-in-the-middle attacks.
61    danger_accept_invalid_hostnames: Option<bool>,
62}
63
64impl From<InstanceAddressDefinition> for InstanceAddress {
65    fn from(address: InstanceAddressDefinition) -> Self {
66        InstanceAddress {
67            hostname: address.hostname,
68            port: address.port,
69            secure: address.secure.unwrap_or(false),
70            user_agent: address.user_agent.unwrap_or(DEFAULT_USER_AGENT.to_owned()),
71            endpoint_graphql: address.endpoint_graphql.unwrap_or(DEFAULT_ENDPOINT_GRAPHQL.to_owned()),
72            endpoint_dynamic_graph: address.endpoint_dynamic_graph.unwrap_or(DEFAULT_ENDPOINT_DYNAMIC_GRAPH.to_owned()),
73            endpoint_runtime: address.endpoint_runtime.unwrap_or(DEFAULT_ENDPOINT_RUNTIME.to_owned()),
74            endpoint_plugin: address.endpoint_plugin.unwrap_or(DEFAULT_ENDPOINT_PLUGIN.to_owned()),
75            bearer: address.bearer,
76            danger_accept_invalid_certs: address.danger_accept_invalid_certs,
77            danger_accept_invalid_hostnames: address.danger_accept_invalid_hostnames,
78        }
79    }
80}