reactive_graph_client/client/plugin/queries/
get_all.rs1#[cynic::schema_for_derives(file = r#"../../schema/graphql/reactive-graph-plugin-schema.graphql"#, module = "crate::schema_plugin::schema")]
2pub mod queries {
3 use crate::schema_plugin::plugin::Plugin;
4
5 #[derive(cynic::QueryFragment, Debug)]
6 #[cynic(graphql_type = "Query")]
7 pub struct GetAllPlugins {
8 pub plugins: Vec<Plugin>,
9 }
10
11 pub fn get_all() -> cynic::Operation<GetAllPlugins, ()> {
12 use cynic::QueryBuilder;
13 GetAllPlugins::build(())
14 }
15}
16
17#[cfg(all(test, feature = "integration-tests"))]
18pub mod test {
19 use crate::ReactiveGraphClient;
20 use reactive_graph_runtime_api::Runtime;
21 use reactive_graph_runtime_impl::RuntimeBuilder;
22 use std::sync::Arc;
23 use std::time::Duration;
24 use tokio::time::sleep;
25
26 #[tokio::test(flavor = "multi_thread")]
27 async fn test_get_all_plugins() {
28 RuntimeBuilder::new()
29 .ignore_config_files()
30 .disable_all_plugins(true)
31 .pick_free_port()
32 .init()
33 .await
34 .post_init()
35 .await
36 .spawn()
37 .await
38 .with_runtime(|runtime: Arc<dyn Runtime + Send + Sync>| async move {
39 sleep(Duration::from_millis(2000)).await;
40
41 let plugin_container_manager = runtime.get_plugin_container_manager();
42 assert_eq!(plugin_container_manager.get_plugins().len(), 0);
43
44 let client = ReactiveGraphClient::new(runtime.address()).expect("Cannot create client");
46 let plugins = client.plugins().get_all().await.expect("Failed to get list of plugins");
47 assert_eq!(plugins.len(), 0);
48 })
49 .await
50 .stop()
51 .await
52 .pre_shutdown()
53 .await
54 .shutdown()
55 .await;
56 }
57}