reactive_graph/client/introspection/
mod.rs

1use std::sync::Arc;
2
3use crate::client::error::CommandError;
4use crate::client::introspection::args::IntrospectionQueryArgs;
5use crate::client::introspection::commands::IntrospectionQueryCommands;
6use crate::client::result::CommandResult;
7use reactive_graph_client::ReactiveGraphClient;
8
9pub(crate) mod args;
10pub(crate) mod commands;
11
12pub(crate) async fn introspection_query(client: &Arc<ReactiveGraphClient>, args: IntrospectionQueryArgs) -> CommandResult {
13    let Some(command) = args.commands else {
14        return Err(CommandError::MissingSubCommand);
15    };
16    match command {
17        IntrospectionQueryCommands::ReactiveGraph => match client.introspection_query_reactive_graph().await {
18            Ok(schema) => Ok(schema.to_sdl().into()),
19            Err(e) => Err(e.into()),
20        },
21        IntrospectionQueryCommands::DynamicGraph => match client.introspection_query_dynamic_graph().await {
22            Ok(schema) => Ok(schema.to_sdl().into()),
23            Err(e) => Err(e.into()),
24        },
25        IntrospectionQueryCommands::ReactiveGraphRuntime => match client.introspection_query_reactive_graph_runtime().await {
26            Ok(schema) => Ok(schema.to_sdl().into()),
27            Err(e) => Err(e.into()),
28        },
29        IntrospectionQueryCommands::ReactiveGraphPlugins => match client.introspection_query_reactive_graph_plugins().await {
30            Ok(schema) => Ok(schema.to_sdl().into()),
31            Err(e) => Err(e.into()),
32        },
33    }
34}