Skip to content

Commit 3b94f1d

Browse files
AutoProcProgram resolvers
1 parent 95c5298 commit 3b94f1d

File tree

2 files changed

+57
-4
lines changed

2 files changed

+57
-4
lines changed

processed_data/src/graphql/entities.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl From<auto_proc::Model> for AutoProc {
114114

115115
/// Represents an auto processed program
116116
#[derive(Clone, Debug, PartialEq, SimpleObject)]
117-
#[graphql(name = "AutoProcProgram", unresolvable)]
117+
#[graphql(name = "AutoProcProgram", unresolvable, complex)]
118118
pub struct AutoProcProgram {
119119
/// An opaque unique identifier for the auto processing program
120120
pub auto_proc_program_id: u32,
@@ -142,7 +142,7 @@ impl From<auto_proc_program::Model> for AutoProcProgram {
142142

143143
/// Represents an auto processing integration
144144
#[derive(Clone, Debug, PartialEq, SimpleObject)]
145-
#[graphql(name = "AutoProcIntegration", unresolvable)]
145+
#[graphql(name = "AutoProcIntegration", unresolvable, complex)]
146146
pub struct AutoProcIntegration {
147147
/// An opaque unique identifier for the auto processing integration
148148
pub auto_proc_integration_id: u32,

processed_data/src/graphql/mod.rs

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@ use async_graphql::{
55
ComplexObject, Context, EmptyMutation, EmptySubscription, Object, Schema, SchemaBuilder,
66
};
77
use aws_sdk_s3::presigning::PresigningConfig;
8-
use entities::{DataCollection, DataProcessing, ProcessingJob, ProcessingJobParameter, AutoProcIntegration};
9-
use models::{data_collection_file_attachment, processing_job, processing_job_parameter, auto_proc_integration};
8+
use entities::{
9+
AutoProcIntegration, DataCollection, DataProcessing, ProcessingJob, ProcessingJobParameter,
10+
AutoProc, AutoProcScaling,
11+
};
12+
use models::{
13+
auto_proc_integration, auto_proc_program, data_collection_file_attachment, processing_job,
14+
processing_job_parameter, auto_proc, auto_proc_scaling,
15+
};
1016
use sea_orm::{ColumnTrait, DatabaseConnection, EntityTrait, QueryFilter};
1117
use std::time::Duration;
1218
use url::Url;
1319

20+
use self::entities::AutoProcProgram;
21+
1422
/// The GraphQL schema exposed by the service
1523
pub type RootSchema = Schema<Query, EmptyMutation, EmptySubscription>;
1624

@@ -92,11 +100,56 @@ impl ProcessingJob {
92100
}
93101
}
94102

103+
#[ComplexObject]
104+
impl AutoProcIntegration {
105+
async fn auto_proc_program(
106+
&self,
107+
ctx: &Context<'_>,
108+
) -> async_graphql::Result<Vec<AutoProcProgram>> {
109+
let database = ctx.data::<DatabaseConnection>()?;
110+
Ok(auto_proc_program::Entity::find()
111+
.filter(auto_proc_program::Column::AutoProcProgramId.eq(self.auto_proc_program_id))
112+
.all(database)
113+
.await?
114+
.into_iter()
115+
.map(AutoProcProgram::from)
116+
.collect())
117+
}
118+
}
119+
120+
#[ComplexObject]
121+
impl AutoProcProgram {
122+
async fn auto_proc(&self, ctx: &Context<'_>,) -> async_graphql::Result<Option<AutoProc>> {
123+
let database = ctx.data::<DatabaseConnection>()?;
124+
Ok(auto_proc::Entity::find()
125+
.filter(auto_proc::Column::AutoProcProgramId.eq(self.auto_proc_program_id))
126+
.one(database)
127+
.await?
128+
.map(AutoProc::from)
129+
)
130+
}
131+
}
132+
95133
#[Object]
96134
impl Query {
97135
/// Reference datasets resolver for the router
98136
#[graphql(entity)]
99137
async fn router_data_collection(&self, id: u32) -> DataCollection {
100138
DataCollection { id }
101139
}
140+
141+
async fn auto_proc_integration(
142+
&self,
143+
ctx: &Context<'_>,
144+
data_collection_id: u32,
145+
) -> async_graphql::Result<Vec<AutoProcIntegration>, async_graphql::Error> {
146+
let database = ctx.data::<DatabaseConnection>()?;
147+
Ok(auto_proc_integration::Entity::find()
148+
.filter(auto_proc_integration::Column::DataCollectionId.eq(data_collection_id))
149+
.all(database)
150+
.await?
151+
.into_iter()
152+
.map(AutoProcIntegration::from)
153+
.collect())
154+
}
102155
}

0 commit comments

Comments
 (0)