pub use queries::*;
#[cynic::schema_for_derives(file = r#"src/backend/schema.graphql"#, module = "schema")]
mod queries {
use serde::Serialize;
use super::schema;
#[derive(cynic::QueryVariables, Debug)]
pub struct GetUserAppsVariables {
pub username: String,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query")]
pub struct GetCurrentUser {
pub viewer: Option<UserWithNamespaces>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct User {
pub id: cynic::Id,
pub username: String,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct Package {
pub id: cynic::Id,
pub name: String,
pub namespace: Option<String>,
pub last_version: Option<PackageVersion>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct PackageVersion {
pub id: cynic::Id,
pub version: String,
pub created_at: DateTime,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct GetPackageVariables {
pub name: String,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "GetPackageVariables")]
pub struct GetPackage {
#[arguments(name: $name)]
pub get_package: Option<Package>,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query")]
pub struct GetCurrentUserWithApps {
pub viewer: Option<UserWithApps>,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "User")]
pub struct UserWithApps {
pub id: cynic::Id,
pub username: String,
pub apps: DeployAppConnection,
}
#[derive(cynic::QueryFragment, Serialize, Debug)]
pub struct Owner {
pub global_name: String,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "User")]
pub struct UserWithNamespaces {
pub id: cynic::Id,
pub username: String,
pub namespaces: NamespaceConnection,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "GetUserAppsVariables")]
pub struct GetUserApps {
#[arguments(username: $username)]
pub get_user: Option<User>,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct GetDeployAppVariables {
pub name: String,
pub owner: String,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "GetDeployAppVariables")]
pub struct GetDeployApp {
#[arguments(owner: $owner, name: $name)]
pub get_deploy_app: Option<DeployApp>,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct GetDeployAppAndVersionVariables {
pub name: String,
pub owner: String,
pub version: String,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "GetDeployAppAndVersionVariables")]
pub struct GetDeployAppAndVersion {
#[arguments(owner: $owner, name: $name)]
pub get_deploy_app: Option<DeployApp>,
#[arguments(owner: $owner, name: $name, version: $version)]
pub get_deploy_app_version: Option<DeployAppVersion>,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct GetDeployAppVersionVariables {
pub name: String,
pub owner: String,
pub version: String,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "GetDeployAppVersionVariables")]
pub struct GetDeployAppVersion {
#[arguments(owner: $owner, name: $name, version: $version)]
pub get_deploy_app_version: Option<DeployAppVersion>,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct CreateNamespaceVariables {
pub name: String,
pub description: Option<String>,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Mutation", variables = "CreateNamespaceVariables")]
pub struct CreateNamespace {
#[arguments(input: {name: $name, description: $description})]
pub create_namespace: Option<CreateNamespacePayload>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct CreateNamespacePayload {
pub namespace: Namespace,
}
#[derive(cynic::InputObject, Debug)]
pub struct CreateNamespaceInput {
pub name: String,
pub display_name: Option<String>,
pub description: Option<String>,
pub avatar: Option<String>,
pub client_mutation_id: Option<String>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct NamespaceEdge {
pub node: Option<Namespace>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct NamespaceConnection {
pub edges: Vec<Option<NamespaceEdge>>,
}
#[derive(cynic::QueryFragment, Serialize, Debug)]
pub struct Namespace {
pub id: cynic::Id,
pub name: String,
}
#[derive(cynic::QueryFragment, Serialize, Debug)]
pub struct DeployApp {
pub id: cynic::Id,
pub name: String,
pub created_at: DateTime,
pub description: Option<String>,
pub active_version: DeployAppVersion,
pub owner: Owner,
}
#[derive(cynic::QueryFragment, Serialize, Debug, Clone)]
pub struct DeployAppVersion {
pub id: cynic::Id,
pub created_at: DateTime,
pub version: String,
pub description: Option<String>,
pub yaml_config: Option<String>,
pub config: String,
pub json_config: String,
pub url: String,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct DeployAppConnection {
pub page_info: PageInfo,
pub edges: Vec<Option<DeployAppEdge>>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct DeployAppEdge {
pub node: Option<DeployApp>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct PageInfo {
pub has_next_page: bool,
pub end_cursor: Option<String>,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct GetNamespaceVariables {
pub name: String,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "GetNamespaceVariables")]
pub struct GetNamespace {
#[arguments(name: $name)]
pub get_namespace: Option<Namespace>,
}
#[derive(cynic::Scalar, Debug, Clone)]
pub struct DateTime(pub String);
#[derive(cynic::QueryVariables, Debug)]
pub struct GetNamespaceAppsVariables {
pub name: String,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "GetNamespaceAppsVariables")]
pub struct GetNamespaceApps {
#[arguments(name: $name)]
pub get_namespace: Option<NamespaceWithApps>,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Namespace")]
pub struct NamespaceWithApps {
pub id: cynic::Id,
pub name: String,
pub apps: DeployAppConnection,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct PublishDeployAppVariables {
pub config: String,
pub name: cynic::Id,
pub owner: Option<cynic::Id>,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Mutation", variables = "PublishDeployAppVariables")]
pub struct PublishDeployApp {
#[arguments(input: { config: { yamlConfig: $config }, name: $name, owner: $owner })]
pub publish_deploy_app: Option<PublishDeployAppPayload>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct PublishDeployAppPayload {
pub deploy_app_version: DeployAppVersion,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct GenerateDeployTokenVariables {
pub app_version_id: String,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Mutation", variables = "GenerateDeployTokenVariables")]
pub struct GenerateDeployToken {
#[arguments(input: { deployConfigVersionId: $app_version_id })]
pub generate_deploy_token: Option<GenerateDeployTokenPayload>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct GenerateDeployTokenPayload {
pub token: String,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct GetDeployAppLogsVariables {
pub name: String,
pub owner: String,
pub version: Option<String>,
pub starting_from: f64,
pub until: Option<f64>,
pub first: Option<i32>,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "GetDeployAppLogsVariables")]
pub struct GetDeployAppLogs {
#[arguments(name: $name, owner: $owner, version: $version)]
pub get_deploy_app_version: Option<DeployAppVersionLogs>,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(
graphql_type = "DeployAppVersion",
variables = "GetDeployAppLogsVariables"
)]
pub struct DeployAppVersionLogs {
#[arguments(startingFrom: $starting_from, until: $until, first: $first)]
pub logs: LogConnection,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct LogConnection {
pub edges: Vec<Option<LogEdge>>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct LogEdge {
pub node: Option<Log>,
}
#[derive(cynic::QueryFragment, Debug, serde::Serialize, PartialEq)]
pub struct Log {
pub message: String,
pub timestamp: f64,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct GenerateDeployConfigTokenVariables {
pub input: String,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(
graphql_type = "Mutation",
variables = "GenerateDeployConfigTokenVariables"
)]
pub struct GenerateDeployConfigToken {
#[arguments(input: { config: $input })]
pub generate_deploy_config_token: Option<GenerateDeployConfigTokenPayload>,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct GenerateDeployConfigTokenPayload {
pub token: String,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct GetDeployAppByIdVars {
pub app_id: cynic::Id,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "GetDeployAppByIdVars")]
pub struct GetDeployAppById {
#[arguments(id: $app_id)]
#[cynic(rename = "node")]
pub app: Option<Node>,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct GetDeployAppAndVersionByIdVars {
pub app_id: cynic::Id,
pub version_id: cynic::Id,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "GetDeployAppAndVersionByIdVars")]
pub struct GetDeployAppAndVersionById {
#[arguments(id: $app_id)]
#[cynic(rename = "node")]
pub app: Option<Node>,
#[arguments(id: $version_id)]
#[cynic(rename = "node")]
pub version: Option<Node>,
}
#[derive(cynic::InlineFragments, Debug)]
pub enum Node {
DeployApp(DeployApp),
DeployAppVersion(DeployAppVersion),
#[cynic(fallback)]
Unknown,
}
impl Node {
pub fn into_deploy_app(self) -> Option<DeployApp> {
match self {
Node::DeployApp(app) => Some(app),
_ => None,
}
}
pub fn into_deploy_app_version(self) -> Option<DeployAppVersion> {
match self {
Node::DeployAppVersion(version) => Some(version),
_ => None,
}
}
}
}
#[allow(non_snake_case, non_camel_case_types)]
mod schema {
cynic::use_schema!(r#"src/backend/schema.graphql"#);
}