Skip to content

Commit b9aa50e

Browse files
mrtnzlmlkodiakhq[bot]
authored andcommitted
YCR: validate 'mobileEntrypointSections' query key
1 parent 971ec56 commit b9aa50e

File tree

20 files changed

+227
-27
lines changed

20 files changed

+227
-27
lines changed

src/ya-comiste-rust/Cargo.lock

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

src/ya-comiste-rust/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[workspace]
22
members = [
33
"crates/arangodb",
4+
"crates/graphql",
5+
"crates/sdui",
46
"crates/server",
57
]

src/ya-comiste-rust/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ This server is written in Rust, exposes GraphQL API (via Warp) and works with Ar
99
```text
1010
(cd src/ya-comiste-rust && cargo run)
1111
(cd src/ya-comiste-rust && cargo fmt)
12-
(cd src/ya-comiste-rust && cargo check)
1312
(cd src/ya-comiste-rust && cargo clippy)
1413
(cd src/ya-comiste-rust && cargo test --offline)
1514
```
@@ -26,13 +25,13 @@ brew services start arangodb
2625
/usr/local/opt/arangodb/sbin/arangod
2726
```
2827

29-
- http://127.0.0.1:8529/ (user `ya-comiste`, no password)
28+
- http://127.0.0.1:8529/ (user `ya-comiste-rust`, no password)
3029

3130
Example query:
3231

3332
```graphql
3433
{
35-
mobileEntrypointSections(id: "entrypoints/com.yaComiste.Explore") {
34+
mobileEntrypointSections(key: "com.yaComiste.Explore") {
3635
id
3736
title
3837
}
@@ -58,6 +57,10 @@ RETURN vertex
5857

5958
See graph traversals: https://www.arangodb.com/docs/stable/aql/graphs-traversals.html
6059

60+
- `_id` - document handle (uniquely identifies a document in the database)
61+
- `_key` - document's primary key (uniquely identifies a document in the collection it is stored in)
62+
- `_rev` - document revision
63+
6164
## Arangodump & Arangorestore
6265

6366
Database backup (empty password):

src/ya-comiste-rust/crates/arangodb/src/lib.rs

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,40 @@ const ARANGODB_HOST: &str = "http://127.0.0.1:8529/";
22
const NORMAL_USERNAME: &str = "ya-comiste-rust"; // TODO: change!
33
const NORMAL_PASSWORD: &str = ""; // TODO: change!
44

5+
/// Default ArangoDB (normal) user:
6+
///
7+
/// ```
8+
/// use arangodb::get_normal_user;
9+
/// assert_eq!(get_normal_user(), "ya-comiste-rust")
10+
/// ```
11+
///
12+
/// Custom ArangoDB (normal) user (via ENV):
13+
///
14+
/// ```
15+
/// use arangodb::get_normal_user;
16+
/// std::env::set_var("ARANGO_USER", "yadada");
17+
/// assert_eq!(get_normal_user(), "yadada")
18+
/// ```
519
pub fn get_normal_user() -> String {
6-
std::env::var("ARANGO_USER").unwrap_or(NORMAL_USERNAME.to_owned())
20+
std::env::var("ARANGO_USER").unwrap_or_else(|_| NORMAL_USERNAME.to_owned())
721
}
822

23+
/// Default ArangoDB (normal) password:
24+
///
25+
/// ```
26+
/// use arangodb::get_normal_password;
27+
/// assert_eq!(get_normal_password(), "")
28+
/// ```
29+
///
30+
/// Custom ArangoDB (normal) password (via ENV):
31+
///
32+
/// ```
33+
/// use arangodb::get_normal_password;
34+
/// std::env::set_var("ARANGO_PASSWORD", "custom_pswd");
35+
/// assert_eq!(get_normal_password(), "custom_pswd")
36+
/// ```
937
pub fn get_normal_password() -> String {
10-
std::env::var("ARANGO_PASSWORD").unwrap_or(NORMAL_PASSWORD.to_owned())
38+
std::env::var("ARANGO_PASSWORD").unwrap_or_else(|_| NORMAL_PASSWORD.to_owned())
1139
}
1240

1341
/// Default ArangoDB host:
@@ -27,7 +55,7 @@ pub fn get_normal_password() -> String {
2755
pub fn get_arangodb_host() -> String {
2856
std::env::var("ARANGODB_HOST")
2957
.map(|s| format!("http://{}", s))
30-
.unwrap_or(ARANGODB_HOST.to_owned())
58+
.unwrap_or_else(|_| ARANGODB_HOST.to_owned())
3159
}
3260

3361
pub async fn connection() -> arangors::Connection {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "graphql"
3+
version = "0.0.0"
4+
authors = ["Martin Zlámal <[email protected]>"]
5+
edition = "2018"
6+
publish = false
7+
8+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9+
10+
[dependencies]
11+
juniper = { git = "https://github.com/graphql-rust/juniper" }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod graphql_context;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "sdui"
3+
version = "0.0.0"
4+
authors = ["Martin Zlámal <[email protected]>"]
5+
edition = "2018"
6+
publish = false
7+
8+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9+
10+
[dependencies]
11+
arangodb = { path = "../arangodb" }
12+
arangors = "0.4.5"
13+
graphql = { path = "../graphql" }
14+
juniper = { git = "https://github.com/graphql-rust/juniper" }
15+
serde = "1.0.117"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This package is responsible for managing Server Driven UI (SDUI).
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use graphql::graphql_context::Context;
2+
3+
/// TODO: maybe `MobileEntrypoint` would be a better name so we are future proof?
4+
#[derive(Clone, Debug, serde::Deserialize)]
5+
pub struct Entrypoint {
6+
pub _id: juniper::ID,
7+
pub _key: String,
8+
}
9+
10+
#[juniper::graphql_object(context = Context)]
11+
impl Entrypoint {
12+
fn id(&self) -> &str {
13+
&self._id
14+
}
15+
}

0 commit comments

Comments
 (0)