Skip to content

Commit 4643671

Browse files
committed
* MS all the GQLSet_MYTYPE structs are generated by a shared macro. (prompted by the desire to have extra, optional fields exposed for each gql-set, for making them compatible with both the old and new mobx-graphlink list-request structure)
1 parent 300007d commit 4643671

28 files changed

Lines changed: 148 additions & 157 deletions

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
"FOR_RUST_ANALYZER": "1",
5454
"STRIP_ASYNC_GRAPHQL": "1",
5555
},
56+
"rust-analyzer.cargo.features": [
57+
"rust-analyzer",
58+
],
5659
"rust-analyzer.runnableEnv": {
5760
// this allows us to use unstable features (as is true for the Docker builds), without rust-analyzer showing an error on the "#![feature(XXX)]" line
5861
//"RUSTC_BOOTSTRAP": "1", // not needed anymore

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/app-server/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dyn-clone = "1.0.4"
3131
oauth2 = "4.4.2"
3232
dotenv = "0.15.0"
3333
lexicon_fractional_index = "0.0.3"
34+
pastey = "0.1.0"
3435

3536
# temp-fix for https://github.com/tikv/pprof-rs/issues/232
3637
#pprof = {git = "https://github.com/Erigara/pprof-rs", branch = "fix-pointer-align"}
@@ -68,4 +69,7 @@ thiserror = "1.0.61"
6869
# v-desktop, base #1: 9m11s (8m5s + 1m6s)
6970
# v-desktop, base #2: 7m17s (6m14s + 1m3s)
7071
# v-desktop, with volumes, no base-build #1: 30s
71-
# v-desktop, with volumes, no base-build #2: 1.355s (cargo build realized that nothing actually needed recompiling)
72+
# v-desktop, with volumes, no base-build #2: 1.355s (cargo build realized that nothing actually needed recompiling)
73+
74+
[features]
75+
rust-analyzer = []

Packages/app-server/src/db/_general.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct PingResult {
127127
async fn linkPreserver(&self, _ctx: &async_graphql::Context<'_>, input: LinkPreserverInput) -> impl Stream<Item = Result<LinkPreserverResult, SubError>> {
128128
let base_stream = async_stream::stream! {
129129
let LinkPreserverInput { updateInterval } = input;
130-
if (updateInterval < 10000) { Err(SubError::new(format!("Update-interval cannot be lower than 10000ms.")))?; }
130+
if updateInterval < 10000 { Err(SubError::new(format!("Update-interval cannot be lower than 10000ms.")))?; }
131131

132132
let mut refresh_requested_last_iteration = Path::new("./refreshPageForAllUsers_enabled").exists();
133133
loop {

Packages/app-server/src/db/access_policies.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ use rust_shared::anyhow::{anyhow, Error};
55
use rust_shared::async_graphql::{Context, InputObject, Object, OutputType, Schema, SimpleObject, Subscription, ID};
66
use rust_shared::db_constants::SYSTEM_USER_ID;
77
use rust_shared::indexmap::IndexMap;
8-
use rust_shared::rust_macros::wrap_slow_macros;
8+
use rust_shared::rust_macros::{self, wrap_slow_macros};
99
use rust_shared::serde::{Deserialize, Serialize};
1010
use rust_shared::serde_json::json;
1111
use rust_shared::tokio_postgres::Client;
1212
use rust_shared::tokio_postgres::Row;
1313
use rust_shared::utils::type_aliases::JSONValue;
1414
use rust_shared::{async_graphql, serde, serde_json, GQLError, SubError};
1515

16+
use crate::gql_set_impl;
1617
use crate::utils::db::accessors::{get_db_entries, get_db_entry, AccessorContext};
1718
use crate::utils::db::generic_handlers::queries::{handle_generic_gql_collection_query, handle_generic_gql_doc_query};
1819
use crate::utils::db::{
@@ -46,12 +47,7 @@ pub async fn get_system_access_policy(ctx: &AccessorContext<'_>, name: &str) ->
4647

4748
wrap_slow_macros! {
4849

49-
#[derive(Clone)] pub struct GQLSet_AccessPolicy { pub nodes: Vec<AccessPolicy> }
50-
#[Object] impl GQLSet_AccessPolicy { async fn nodes(&self) -> &Vec<AccessPolicy> { &self.nodes } }
51-
impl GQLSet<AccessPolicy> for GQLSet_AccessPolicy {
52-
fn from(entries: Vec<AccessPolicy>) -> GQLSet_AccessPolicy { Self { nodes: entries } }
53-
fn nodes(&self) -> &Vec<AccessPolicy> { &self.nodes }
54-
}
50+
gql_set_impl!(AccessPolicy);
5551

5652
#[derive(Default)] pub struct QueryShard_AccessPolicy;
5753
#[Object] impl QueryShard_AccessPolicy {

Packages/app-server/src/db/command_runs.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use rust_shared::serde::{Deserialize, Serialize};
55
use rust_shared::tokio_postgres::{Client, Row};
66
use rust_shared::{async_graphql, serde, serde_json, GQLError, SubError};
77

8+
use crate::gql_set_impl;
89
use crate::utils::db::generic_handlers::queries::{handle_generic_gql_collection_query, handle_generic_gql_doc_query};
910
use crate::utils::db::pg_row_to_json::postgres_row_to_struct;
1011
use crate::utils::db::{
@@ -69,12 +70,7 @@ impl From<Row> for CommandRun {
6970
fn from(row: Row) -> Self { postgres_row_to_struct(row).unwrap() }
7071
}
7172

72-
#[derive(Clone)] pub struct GQLSet_CommandRun { pub nodes: Vec<CommandRun> }
73-
#[Object] impl GQLSet_CommandRun { async fn nodes(&self) -> &Vec<CommandRun> { &self.nodes } }
74-
impl GQLSet<CommandRun> for GQLSet_CommandRun {
75-
fn from(entries: Vec<CommandRun>) -> GQLSet_CommandRun { Self { nodes: entries } }
76-
fn nodes(&self) -> &Vec<CommandRun> { &self.nodes }
77-
}
73+
gql_set_impl!(CommandRun);
7874

7975
#[derive(Default)] pub struct QueryShard_CommandRun;
8076
#[Object] impl QueryShard_CommandRun {

Packages/app-server/src/db/feedback_proposals.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rust_shared::{
99
serde, GQLError,
1010
};
1111

12+
use crate::gql_set_impl;
1213
use crate::utils::db::generic_handlers::queries::{handle_generic_gql_collection_query, handle_generic_gql_doc_query};
1314
use crate::utils::db::{
1415
filter::FilterInput,
@@ -33,12 +34,7 @@ impl From<Row> for Proposal {
3334
fn from(row: Row) -> Self { postgres_row_to_struct(row).unwrap() }
3435
}
3536

36-
#[derive(Clone)] pub struct GQLSet_Proposal { pub nodes: Vec<Proposal> }
37-
#[Object] impl GQLSet_Proposal { async fn nodes(&self) -> &Vec<Proposal> { &self.nodes } }
38-
impl GQLSet<Proposal> for GQLSet_Proposal {
39-
fn from(entries: Vec<Proposal>) -> GQLSet_Proposal { Self { nodes: entries } }
40-
fn nodes(&self) -> &Vec<Proposal> { &self.nodes }
41-
}
37+
gql_set_impl!(Proposal);
4238

4339
#[derive(Default)] pub struct QueryShard_Proposal;
4440
#[Object] impl QueryShard_Proposal {

Packages/app-server/src/db/feedback_user_infos.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rust_shared::serde::{Deserialize, Serialize};
77
use rust_shared::tokio_postgres::{Client, Row};
88
use rust_shared::{GQLError, SubError};
99

10+
use crate::gql_set_impl;
1011
use crate::utils::db::generic_handlers::queries::{handle_generic_gql_collection_query, handle_generic_gql_doc_query};
1112
use crate::utils::db::{
1213
filter::FilterInput,
@@ -35,12 +36,7 @@ impl From<Row> for UserInfo {
3536
}
3637
}
3738

38-
#[derive(Clone)] pub struct GQLSet_UserInfo { pub nodes: Vec<UserInfo> }
39-
#[Object] impl GQLSet_UserInfo { async fn nodes(&self) -> &Vec<UserInfo> { &self.nodes } }
40-
impl GQLSet<UserInfo> for GQLSet_UserInfo {
41-
fn from(entries: Vec<UserInfo>) -> GQLSet_UserInfo { Self { nodes: entries } }
42-
fn nodes(&self) -> &Vec<UserInfo> { &self.nodes }
43-
}
39+
gql_set_impl!(UserInfo);
4440

4541
#[derive(Default)] pub struct QueryShard_UserInfo;
4642
#[Object] impl QueryShard_UserInfo {

Packages/app-server/src/db/global_data.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use rust_shared::tokio_postgres::{Client, Row};
88
use rust_shared::utils::type_aliases::JSONValue;
99
use rust_shared::{serde_json, GQLError, SubError};
1010

11+
use crate::gql_set_impl;
1112
use crate::utils::db::generic_handlers::queries::{handle_generic_gql_collection_query, handle_generic_gql_doc_query};
1213
use crate::utils::db::{
1314
filter::FilterInput,
@@ -36,12 +37,7 @@ impl From<Row> for GlobalData {
3637
}
3738
}
3839

39-
#[derive(Clone)] pub struct GQLSet_GlobalData { pub nodes: Vec<GlobalData> }
40-
#[Object] impl GQLSet_GlobalData { async fn nodes(&self) -> &Vec<GlobalData> { &self.nodes } }
41-
impl GQLSet<GlobalData> for GQLSet_GlobalData {
42-
fn from(entries: Vec<GlobalData>) -> GQLSet_GlobalData { Self { nodes: entries } }
43-
fn nodes(&self) -> &Vec<GlobalData> { &self.nodes }
44-
}
40+
gql_set_impl!(GlobalData);
4541

4642
#[derive(Default)] pub struct QueryShard_GlobalData;
4743
#[Object] impl QueryShard_GlobalData {

Packages/app-server/src/db/map_node_edits.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rust_shared::tokio_postgres::{Client, Row};
1010
use rust_shared::GQLError;
1111
use rust_shared::SubError;
1212

13+
use crate::gql_set_impl;
1314
use crate::utils::db::accessors::AccessorContext;
1415
use crate::utils::db::generic_handlers::queries::{handle_generic_gql_collection_query, handle_generic_gql_doc_query};
1516
use crate::utils::db::pg_row_to_json::postgres_row_to_struct;
@@ -47,12 +48,7 @@ impl From<Row> for MapNodeEdit {
4748
fn from(row: Row) -> Self { postgres_row_to_struct(row).unwrap() }
4849
}
4950

50-
#[derive(Clone)] pub struct GQLSet_MapNodeEdit { pub nodes: Vec<MapNodeEdit> }
51-
#[Object] impl GQLSet_MapNodeEdit { async fn nodes(&self) -> &Vec<MapNodeEdit> { &self.nodes } }
52-
impl GQLSet<MapNodeEdit> for GQLSet_MapNodeEdit {
53-
fn from(entries: Vec<MapNodeEdit>) -> GQLSet_MapNodeEdit { Self { nodes: entries } }
54-
fn nodes(&self) -> &Vec<MapNodeEdit> { &self.nodes }
55-
}
51+
gql_set_impl!(MapNodeEdit);
5652

5753
#[derive(Default)] pub struct QueryShard_NodeEdit;
5854
#[Object] impl QueryShard_NodeEdit {

0 commit comments

Comments
 (0)