We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 288b449 commit 020d524Copy full SHA for 020d524
src/schema/mod.rs
@@ -745,6 +745,30 @@ impl QueryRoot {
745
Ok(Formation(id))
746
}
747
748
+ async fn images(
749
+ &self,
750
+ ctx: &Context<'_>,
751
+ ) -> Result<Vec<Image>> {
752
+ let data = ctx.data::<AppData>()?;
753
+ let client = match &data.pg_pool {
754
+ Some(pool) => pool.get().await?,
755
+ None => {
756
+ return Err("Database connection is not available".into());
757
+ }
758
+ };
759
+
760
+ let result = client
761
+ .query("SELECT images.id FROM images", &[])
762
+ .await?;
763
764
+ let images = result
765
+ .into_iter()
766
+ .map(|row| row.try_get(0).map(Image))
767
+ .collect::<Result<Vec<Image>, _>>()?;
768
769
+ Ok(images)
770
771
772
async fn image(
773
&self,
774
ctx: &Context<'_>,
0 commit comments