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
43impl From<InstanceAddressDefinition> for InstanceAddress {
44    fn from(address: InstanceAddressDefinition) -> Self {
45        InstanceAddress {
46            hostname: address.hostname,
47            port: address.port,
48            secure: address.secure.unwrap_or(false),
49            user_agent: address.user_agent.unwrap_or(DEFAULT_USER_AGENT.to_owned()),
50            endpoint_graphql: address.endpoint_graphql.unwrap_or(DEFAULT_ENDPOINT_GRAPHQL.to_owned()),
51            endpoint_dynamic_graph: address.endpoint_dynamic_graph.unwrap_or(DEFAULT_ENDPOINT_DYNAMIC_GRAPH.to_owned()),
52            endpoint_runtime: address.endpoint_runtime.unwrap_or(DEFAULT_ENDPOINT_RUNTIME.to_owned()),
53            endpoint_plugin: address.endpoint_plugin.unwrap_or(DEFAULT_ENDPOINT_PLUGIN.to_owned()),
54            bearer: address.bearer,
55        }
56    }
57}