Skip to content

Commit

Permalink
Update reference resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
iamvigneshwars committed Mar 22, 2024
1 parent 40c77de commit 9b359be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
6 changes: 3 additions & 3 deletions datasets/src/graphql/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use models::data_collection;

/// Represents data collected during the sessions
#[derive(Clone, Debug, PartialEq, SimpleObject)]
#[graphql(name = "Datasets")]
#[graphql(name = "Datasets", unresolvable)]
pub struct DataCollection {
/// An opaque unique identifier for the data collection
pub data_collection_id: u32,
pub id: u32,
/// The date time and which data collection began
pub start_time: Option<DateTime<Utc>>,
/// The date time and which data collection ended
Expand Down Expand Up @@ -54,7 +54,7 @@ pub struct Session {
impl From<data_collection::Model> for DataCollection {
fn from(values: data_collection::Model) -> Self {
Self {
data_collection_id: values.data_collection_id,
id: values.data_collection_id,
start_time: values.start_time.map(|time| time.and_utc()),
end_time: values.end_time.map(|time| time.and_utc()),
number_of_images: values.number_of_images,
Expand Down
16 changes: 1 addition & 15 deletions datasets/src/graphql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,7 @@ impl Session {

#[Object]
impl Query {
/// Reference dataset resolver for the router
#[graphql(entity)]
async fn router_dataset(
&self,
ctx: &Context<'_>,
data_collection_id: u32,
) -> Result<Option<DataCollection>, async_graphql::Error> {
let database = ctx.data::<DatabaseConnection>()?;
Ok(data_collection::Entity::find_by_id(data_collection_id)
.one(database)
.await?
.map(DataCollection::from))
}

/// Reference sessions resolver for the router
// /// Reference sessions resolver for the router
#[graphql(entity)]
async fn router_sessions(&self, id: i32) -> Session {
Session { id }
Expand Down

0 comments on commit 9b359be

Please sign in to comment.