Remove legacy graphql stuff
Graphql is dead. Long live gRPC!!!
This commit is contained in:
parent
a681cbb739
commit
f76ba00ce4
|
|
@ -8,17 +8,6 @@ version = "0.11.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3"
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aliasable"
|
||||
version = "0.1.3"
|
||||
|
|
@ -99,12 +88,6 @@ dependencies = [
|
|||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.21.0"
|
||||
|
|
@ -117,40 +100,6 @@ version = "1.3.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitvec"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"
|
||||
dependencies = [
|
||||
"funty",
|
||||
"radium",
|
||||
"tap",
|
||||
"wyz",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bson"
|
||||
version = "2.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9aeb8bae494e49dbc330dd23cf78f6f7accee22f640ce3ab17841badaa4ce232"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"base64 0.13.1",
|
||||
"bitvec",
|
||||
"chrono",
|
||||
"hex",
|
||||
"indexmap",
|
||||
"js-sys",
|
||||
"lazy_static",
|
||||
"rand",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"serde_json",
|
||||
"time",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.12.2"
|
||||
|
|
@ -199,16 +148,6 @@ version = "1.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "combine"
|
||||
version = "3.8.1"
|
||||
|
|
@ -252,10 +191,6 @@ name = "crabidy-core"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures",
|
||||
"graphql_client",
|
||||
"juniper",
|
||||
"juniper_subscriptions",
|
||||
"prost",
|
||||
"serde",
|
||||
"tonic",
|
||||
|
|
@ -364,17 +299,6 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_utils"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "532b4c15dccee12c7044f1fcad956e98410860b22231e44a3b827464797ca7bf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.8.1"
|
||||
|
|
@ -469,27 +393,6 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "funty"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.28"
|
||||
|
|
@ -497,7 +400,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -506,45 +408,6 @@ version = "0.3.28"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c"
|
||||
|
||||
[[package]]
|
||||
name = "futures-enum"
|
||||
version = "0.1.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3422d14de7903a52e9dbc10ae05a7e14445ec61890100e098754e120b2bd7b1e"
|
||||
dependencies = [
|
||||
"derive_utils",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.28"
|
||||
|
|
@ -563,16 +426,10 @@ version = "0.3.28"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-macro",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"memchr",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -588,15 +445,6 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "graphql-introspection-query"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f2a4732cf5140bd6c082434494f785a19cfb566ab07d1382c3671f5812fed6d"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "graphql-parser"
|
||||
version = "0.4.0"
|
||||
|
|
@ -607,45 +455,6 @@ dependencies = [
|
|||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "graphql_client"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa61bb9dc6d373a8b465a5da17b62809483e8527a34b0e9034dc0915b09e160a"
|
||||
dependencies = [
|
||||
"graphql_query_derive",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "graphql_client_codegen"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e55df64cc702c4ad6647f8df13a799ad11688a3781fadf5045f7ba12733fa9b"
|
||||
dependencies = [
|
||||
"graphql-introspection-query",
|
||||
"graphql-parser",
|
||||
"heck",
|
||||
"lazy_static",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "graphql_query_derive"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d52fc9cde811f44b15ec0692b31e56a3067f6f431c5ace712f286e47c1dacc98"
|
||||
dependencies = [
|
||||
"graphql_client_codegen",
|
||||
"proc-macro2",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.3.19"
|
||||
|
|
@ -692,12 +501,6 @@ version = "0.3.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "0.2.9"
|
||||
|
|
@ -805,7 +608,6 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
|||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -858,48 +660,6 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "juniper"
|
||||
version = "0.16.0-dev"
|
||||
source = "git+https://github.com/graphql-rust/juniper.git?branch=master#a648dd727519991c2e3c762af16eac027b2acec2"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bson",
|
||||
"fnv",
|
||||
"futures",
|
||||
"futures-enum",
|
||||
"graphql-parser",
|
||||
"indexmap",
|
||||
"juniper_codegen",
|
||||
"serde",
|
||||
"smartstring",
|
||||
"static_assertions",
|
||||
"url",
|
||||
"uuid",
|
||||
"void",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "juniper_codegen"
|
||||
version = "0.16.0-dev"
|
||||
source = "git+https://github.com/graphql-rust/juniper.git?branch=master#a648dd727519991c2e3c762af16eac027b2acec2"
|
||||
dependencies = [
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "juniper_subscriptions"
|
||||
version = "0.17.0-dev"
|
||||
source = "git+https://github.com/graphql-rust/juniper.git?branch=master#a648dd727519991c2e3c762af16eac027b2acec2"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"juniper",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
|
|
@ -1000,16 +760,6 @@ dependencies = [
|
|||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.15"
|
||||
|
|
@ -1291,12 +1041,6 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "radium"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
|
|
@ -1379,7 +1123,7 @@ version = "0.11.18"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55"
|
||||
dependencies = [
|
||||
"base64 0.21.0",
|
||||
"base64",
|
||||
"bytes",
|
||||
"encoding_rs",
|
||||
"futures-core",
|
||||
|
|
@ -1483,15 +1227,6 @@ dependencies = [
|
|||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_bytes"
|
||||
version = "0.11.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "416bda436f9aab92e02c8e10d49a15ddd339cea90b6e340fe51ed97abb548294"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.163"
|
||||
|
|
@ -1509,7 +1244,6 @@ version = "1.0.96"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
|
|
@ -1572,17 +1306,6 @@ version = "1.10.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
|
||||
|
||||
[[package]]
|
||||
name = "smartstring"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"static_assertions",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.4.9"
|
||||
|
|
@ -1642,12 +1365,6 @@ version = "0.1.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
|
||||
|
||||
[[package]]
|
||||
name = "tap"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.5.0"
|
||||
|
|
@ -1681,33 +1398,6 @@ dependencies = [
|
|||
"syn 2.0.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"serde",
|
||||
"time-core",
|
||||
"time-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time-core"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
|
||||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b"
|
||||
dependencies = [
|
||||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.6.0"
|
||||
|
|
@ -1806,7 +1496,7 @@ checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a"
|
|||
dependencies = [
|
||||
"async-trait",
|
||||
"axum",
|
||||
"base64 0.21.0",
|
||||
"base64",
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
|
|
@ -1962,16 +1652,6 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
|
|
@ -2270,12 +1950,3 @@ checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
|
|||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wyz"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed"
|
||||
dependencies = [
|
||||
"tap",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -7,19 +7,11 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
async-trait = "0.1.68"
|
||||
futures = "0.3.28"
|
||||
graphql_client = "0.12.0"
|
||||
juniper = { git = "https://github.com/graphql-rust/juniper.git", branch = "master" }
|
||||
juniper_subscriptions = { git = "https://github.com/graphql-rust/juniper.git", branch = "master" }
|
||||
prost = "0.11"
|
||||
serde = "1.0.163"
|
||||
tonic = "0.9"
|
||||
|
||||
[build-dependencies]
|
||||
async-trait = "0.1.68"
|
||||
futures = "0.3.28"
|
||||
graphql_client = "0.12.0"
|
||||
juniper = { git = "https://github.com/graphql-rust/juniper.git", branch = "master" }
|
||||
juniper_subscriptions = { git = "https://github.com/graphql-rust/juniper.git", branch = "master" }
|
||||
serde = "1.0.163"
|
||||
tonic-build = "0.9"
|
||||
|
|
|
|||
|
|
@ -1,37 +1,4 @@
|
|||
use juniper::{EmptyMutation, EmptySubscription, IntrospectionFormat};
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
|
||||
#[path = "src/lib.rs"]
|
||||
mod lib;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// --- OLD JUNIPER STUFF ---
|
||||
// let (res, _errors) = juniper::introspect(
|
||||
// &lib::Schema::new(
|
||||
// lib::ItemList::new(),
|
||||
// lib::Queue::new(),
|
||||
// lib::Subscription::new(),
|
||||
// ),
|
||||
// &(),
|
||||
// IntrospectionFormat::default(),
|
||||
// )
|
||||
// .unwrap();
|
||||
// let mut file = File::create("src/schema.json").unwrap();
|
||||
// let json_result = serde_json::to_string_pretty(&res).unwrap();
|
||||
// file.write_all(json_result.as_bytes()).unwrap();
|
||||
|
||||
let schema = lib::Schema::new(
|
||||
lib::ItemList::new(),
|
||||
lib::Mutation::new(),
|
||||
lib::Subscription::new(),
|
||||
);
|
||||
let schema_str = schema.as_schema_language();
|
||||
|
||||
let mut file = File::create("src/schema.graphql").unwrap();
|
||||
file.write_all(schema_str.as_bytes()).unwrap();
|
||||
|
||||
// --- NEW TONIC STUFF ---
|
||||
tonic_build::compile_protos("proto/crabidy.proto")?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,13 @@
|
|||
pub mod proto;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use futures::Stream;
|
||||
use juniper::{
|
||||
graphql_object, graphql_subscription, FieldError, FieldResult, GraphQLEnum, GraphQLInputObject,
|
||||
GraphQLObject, RootNode,
|
||||
};
|
||||
use std::{collections::HashMap, pin::Pin, sync::Arc};
|
||||
|
||||
#[async_trait]
|
||||
pub trait ProviderClient: Send + Sync {
|
||||
pub trait ProviderClient: std::fmt::Debug + Send + Sync {
|
||||
async fn get_urls_for_track(&self, track_uuid: &str) -> Result<Vec<String>, ProviderError>;
|
||||
async fn get_item_lists_full(&self) -> Result<Vec<ItemList>, ProviderError>;
|
||||
async fn get_item_lists_partial(
|
||||
&self,
|
||||
list_uuid: String,
|
||||
) -> Result<Vec<ItemList>, ProviderError>;
|
||||
async fn get_item_list_partial_without_children(
|
||||
&self,
|
||||
list_uuid: String,
|
||||
) -> Result<ItemList, ProviderError>;
|
||||
fn get_root_list(&self) -> ItemList;
|
||||
async fn get_item_list(&self, list_uuid: &str, depth: usize)
|
||||
-> Result<ItemList, ProviderError>;
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Hash)]
|
||||
|
|
@ -32,47 +20,39 @@ pub enum ProviderError {
|
|||
pub struct ItemList {
|
||||
pub name: String,
|
||||
pub uuid: String,
|
||||
pub provider: String,
|
||||
pub parent: String,
|
||||
pub tracks: Option<Vec<Track>>,
|
||||
pub children: Option<Vec<ItemList>>,
|
||||
pub children: Vec<ItemList>,
|
||||
pub is_queable: bool,
|
||||
without_children: bool,
|
||||
}
|
||||
|
||||
#[graphql_object(context = Context)]
|
||||
impl ItemList {
|
||||
fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
fn uuid(&self) -> &str {
|
||||
&self.uuid
|
||||
}
|
||||
fn provider(&self) -> &str {
|
||||
&self.provider
|
||||
}
|
||||
//TODO: Be smarter than clone here
|
||||
fn tracks(&self, refresh: bool) -> Option<Vec<Track>> {
|
||||
self.tracks.clone()
|
||||
}
|
||||
//TODO: Be smarter than clone here
|
||||
fn children(&self, refresh: bool) -> Option<Vec<ItemList>> {
|
||||
self.children.clone()
|
||||
}
|
||||
fn is_queable(&self) -> bool {
|
||||
self.is_queable
|
||||
}
|
||||
pub ephemeral: bool,
|
||||
pub is_partial: bool,
|
||||
}
|
||||
|
||||
impl ItemList {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
name: "root".to_string(),
|
||||
uuid: "root".to_string(),
|
||||
provider: "root".to_string(),
|
||||
name: "/".to_string(),
|
||||
uuid: "/".to_string(),
|
||||
parent: "".to_string(),
|
||||
tracks: None,
|
||||
children: None,
|
||||
children: Vec::new(),
|
||||
is_queable: false,
|
||||
without_children: true,
|
||||
ephemeral: false,
|
||||
is_partial: true,
|
||||
}
|
||||
}
|
||||
pub fn replace_sublist(&mut self, sublist: &Self) {
|
||||
if self.uuid == sublist.uuid {
|
||||
self.name = sublist.name.clone();
|
||||
self.tracks = sublist.tracks.clone();
|
||||
self.children = sublist.children.clone();
|
||||
self.is_queable = sublist.is_queable;
|
||||
self.ephemeral = sublist.ephemeral;
|
||||
self.is_partial = sublist.is_partial;
|
||||
return;
|
||||
}
|
||||
for child in self.children.iter_mut() {
|
||||
child.replace_sublist(sublist);
|
||||
}
|
||||
}
|
||||
pub fn flatten(&self) -> Vec<Track> {
|
||||
|
|
@ -80,16 +60,21 @@ impl ItemList {
|
|||
if let Some(own_tracks) = &self.tracks {
|
||||
tracks.extend(own_tracks.clone());
|
||||
}
|
||||
if let Some(childs) = &self.children {
|
||||
for child in childs {
|
||||
for child in self.children.iter() {
|
||||
tracks.extend(child.flatten());
|
||||
}
|
||||
}
|
||||
tracks
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, GraphQLEnum)]
|
||||
#[derive(Clone, Debug)]
|
||||
struct ItemListFilter {
|
||||
uuid_filter: Option<String>,
|
||||
name_filter: Option<String>,
|
||||
provider_filter: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
enum PlayState {
|
||||
Buffering,
|
||||
Playing,
|
||||
|
|
@ -97,7 +82,7 @@ enum PlayState {
|
|||
Stopped,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, GraphQLObject)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Track {
|
||||
pub title: String,
|
||||
pub uuid: String,
|
||||
|
|
@ -107,19 +92,19 @@ pub struct Track {
|
|||
pub provider: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, GraphQLInputObject)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct InputTrack {
|
||||
pub uuid: String,
|
||||
pub provider: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, GraphQLObject)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Album {
|
||||
pub title: String,
|
||||
pub release_date: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, GraphQLObject)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Artist {
|
||||
pub name: String,
|
||||
}
|
||||
|
|
@ -129,7 +114,7 @@ pub enum QueueError {
|
|||
ItemListNotQueuable,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, GraphQLObject)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Queue {
|
||||
pub tracks: Vec<Track>,
|
||||
current: i32,
|
||||
|
|
@ -215,58 +200,6 @@ impl Queue {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Mutation;
|
||||
|
||||
impl Mutation {
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
#[graphql_object(context = Context)]
|
||||
impl Mutation {
|
||||
fn playpause(&self, track: InputTrack) -> FieldResult<ActiveTrack> {
|
||||
Ok(ActiveTrack::new())
|
||||
}
|
||||
fn stop(&self, track: InputTrack) -> FieldResult<ActiveTrack> {
|
||||
Ok(ActiveTrack::new())
|
||||
}
|
||||
fn previous(&self, track: InputTrack) -> FieldResult<ActiveTrack> {
|
||||
Ok(ActiveTrack::new())
|
||||
}
|
||||
fn next(&self, track: InputTrack) -> FieldResult<ActiveTrack> {
|
||||
Ok(ActiveTrack::new())
|
||||
}
|
||||
fn seek(&self, track: InputTrack, millis: i32) -> FieldResult<ActiveTrack> {
|
||||
Ok(ActiveTrack::new())
|
||||
}
|
||||
fn append(&self, tracks: Vec<InputTrack>) -> FieldResult<Success> {
|
||||
Ok(Success::Appending)
|
||||
}
|
||||
fn queue(&self, tracks: Vec<InputTrack>) -> FieldResult<Success> {
|
||||
Ok(Success::Queuing)
|
||||
}
|
||||
fn replace(&self, tracks: Vec<InputTrack>) -> FieldResult<Success> {
|
||||
Ok(Success::Replacing)
|
||||
}
|
||||
fn delete(&self, track: InputTrack) -> FieldResult<Success> {
|
||||
Ok(Success::Deleting)
|
||||
}
|
||||
fn clear(&self, track: InputTrack) -> FieldResult<Success> {
|
||||
Ok(Success::Clearing)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, GraphQLEnum)]
|
||||
enum Success {
|
||||
Appending,
|
||||
Replacing,
|
||||
Queuing,
|
||||
Deleting,
|
||||
Clearing,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, GraphQLObject)]
|
||||
pub struct ActiveTrack {
|
||||
track: Option<Track>,
|
||||
completion: i32,
|
||||
|
|
@ -282,49 +215,3 @@ impl ActiveTrack {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
type ActiveTrackStream = Pin<Box<dyn Stream<Item = Result<ActiveTrack, FieldError>> + Send>>;
|
||||
type QueueStream = Pin<Box<dyn Stream<Item = Result<Queue, FieldError>> + Send>>;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Subscription {
|
||||
queue: Queue,
|
||||
active_track: Option<ActiveTrack>,
|
||||
}
|
||||
|
||||
#[graphql_subscription(context = Context)]
|
||||
impl Subscription {
|
||||
async fn queue() -> QueueStream {
|
||||
let stream = futures::stream::iter(vec![Ok(Queue::new())]);
|
||||
Box::pin(stream)
|
||||
}
|
||||
async fn active_track() -> ActiveTrackStream {
|
||||
let stream = futures::stream::iter(vec![Ok(ActiveTrack::new())]);
|
||||
Box::pin(stream)
|
||||
}
|
||||
}
|
||||
|
||||
impl Subscription {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
queue: Queue::new(),
|
||||
active_track: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Context {
|
||||
clients: HashMap<String, Arc<dyn ProviderClient>>,
|
||||
queue: Queue,
|
||||
}
|
||||
|
||||
impl Context {
|
||||
pub fn new(clients: HashMap<String, Arc<dyn ProviderClient>>) -> Self {
|
||||
let queue = Queue::new();
|
||||
Self { clients, queue }
|
||||
}
|
||||
}
|
||||
|
||||
impl juniper::Context for Context {}
|
||||
|
||||
pub type Schema = RootNode<'static, ItemList, Mutation, Subscription>;
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
query ItemList {
|
||||
name
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
#![allow(clippy::all, warnings)]
|
||||
pub struct ItemList;
|
||||
pub mod item_list {
|
||||
#![allow(dead_code)]
|
||||
use std::result::Result;
|
||||
pub const OPERATION_NAME: &str = "ItemList";
|
||||
pub const QUERY: &str = "query ItemList {\n name\n}\n";
|
||||
use super::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[allow(dead_code)]
|
||||
type Boolean = bool;
|
||||
#[allow(dead_code)]
|
||||
type Float = f64;
|
||||
#[allow(dead_code)]
|
||||
type Int = i64;
|
||||
#[allow(dead_code)]
|
||||
type ID = String;
|
||||
#[derive(Serialize)]
|
||||
pub struct Variables;
|
||||
#[derive(Deserialize)]
|
||||
pub struct ResponseData {
|
||||
pub name: String,
|
||||
}
|
||||
}
|
||||
impl graphql_client::GraphQLQuery for ItemList {
|
||||
type Variables = item_list::Variables;
|
||||
type ResponseData = item_list::ResponseData;
|
||||
fn build_query(variables: Self::Variables) -> ::graphql_client::QueryBody<Self::Variables> {
|
||||
graphql_client::QueryBody {
|
||||
variables,
|
||||
query: item_list::QUERY,
|
||||
operation_name: item_list::OPERATION_NAME,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
type Queue {
|
||||
tracks: [Track!]!
|
||||
current: Int!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
playpause(track: InputTrack!): ActiveTrack!
|
||||
stop(track: InputTrack!): ActiveTrack!
|
||||
previous(track: InputTrack!): ActiveTrack!
|
||||
next(track: InputTrack!): ActiveTrack!
|
||||
seek(track: InputTrack!, millis: Int!): ActiveTrack!
|
||||
append(tracks: [InputTrack!]!): Success!
|
||||
queue(tracks: [InputTrack!]!): Success!
|
||||
replace(tracks: [InputTrack!]!): Success!
|
||||
delete(track: InputTrack!): Success!
|
||||
clear(track: InputTrack!): Success!
|
||||
}
|
||||
|
||||
type Album {
|
||||
title: String!
|
||||
releaseDate: String
|
||||
}
|
||||
|
||||
enum PlayState {
|
||||
BUFFERING
|
||||
PLAYING
|
||||
PAUSED
|
||||
STOPPED
|
||||
}
|
||||
|
||||
type Subscription {
|
||||
queue: Queue!
|
||||
activeTrack: ActiveTrack!
|
||||
}
|
||||
|
||||
type Artist {
|
||||
name: String!
|
||||
}
|
||||
|
||||
type ActiveTrack {
|
||||
track: Track
|
||||
completion: Int!
|
||||
playState: PlayState!
|
||||
}
|
||||
|
||||
type ItemList {
|
||||
name: String!
|
||||
uuid: String!
|
||||
provider: String!
|
||||
tracks(refresh: Boolean!): [Track!]
|
||||
children(refresh: Boolean!): [ItemList!]
|
||||
isQueable: Boolean!
|
||||
}
|
||||
|
||||
type Track {
|
||||
title: String!
|
||||
uuid: String!
|
||||
duration: Int
|
||||
album: Album
|
||||
artist: Artist
|
||||
provider: String!
|
||||
}
|
||||
|
||||
enum Success {
|
||||
APPENDING
|
||||
REPLACING
|
||||
QUEUING
|
||||
DELETING
|
||||
CLEARING
|
||||
}
|
||||
|
||||
input InputTrack {
|
||||
uuid: String!
|
||||
provider: String!
|
||||
}
|
||||
|
||||
schema {
|
||||
query: ItemList
|
||||
mutation: Mutation
|
||||
subscription: Subscription
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue