@@ -716,6 +716,84 @@ impl MutationRoot {
716716 Ok ( Climb ( climb_id) )
717717 }
718718
719+ async fn describe_crag (
720+ & self ,
721+ ctx : & Context < ' _ > ,
722+ #[ graphql( desc = "Crag id" ) ] id : ID ,
723+ #[ graphql( desc = "Crag description" ) ] description : Option < String > ,
724+ ) -> Result < Crag > {
725+ let id: i32 = id. 0 . parse ( ) . map_err ( |_| "Invalid ID format" ) ?;
726+ let data = ctx. data :: < AppData > ( ) ?;
727+ let client = match & data. pg_pool {
728+ Some ( pool) => pool. get ( ) . await ?,
729+ None => {
730+ return Err ( "Database connection is not available" . into ( ) ) ;
731+ }
732+ } ;
733+
734+ let crag_id = client
735+ . query_one (
736+ "UPDATE climb.crags SET description = $1 WHERE id = $2 RETURNING id" ,
737+ & [ & description, & id] ,
738+ )
739+ . await ?
740+ . get :: < _ , i32 > ( 0 ) ;
741+
742+ Ok ( Crag ( crag_id) )
743+ }
744+
745+ async fn describe_region (
746+ & self ,
747+ ctx : & Context < ' _ > ,
748+ #[ graphql( desc = "Region id" ) ] id : ID ,
749+ #[ graphql( desc = "Region description" ) ] description : Option < String > ,
750+ ) -> Result < Region > {
751+ let id: i32 = id. 0 . parse ( ) . map_err ( |_| "Invalid ID format" ) ?;
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 region_id = client
761+ . query_one (
762+ "UPDATE climb.regions SET description = $1 WHERE id = $2 RETURNING id" ,
763+ & [ & description, & id] ,
764+ )
765+ . await ?
766+ . get :: < _ , i32 > ( 0 ) ;
767+
768+ Ok ( Region ( region_id) )
769+ }
770+
771+ async fn describe_sector (
772+ & self ,
773+ ctx : & Context < ' _ > ,
774+ #[ graphql( desc = "Sector id" ) ] id : ID ,
775+ #[ graphql( desc = "Sector description" ) ] description : Option < String > ,
776+ ) -> Result < Sector > {
777+ let id: i32 = id. 0 . parse ( ) . map_err ( |_| "Invalid ID format" ) ?;
778+ let data = ctx. data :: < AppData > ( ) ?;
779+ let client = match & data. pg_pool {
780+ Some ( pool) => pool. get ( ) . await ?,
781+ None => {
782+ return Err ( "Database connection is not available" . into ( ) ) ;
783+ }
784+ } ;
785+
786+ let sector_id = client
787+ . query_one (
788+ "UPDATE climb.sectors SET description = $1 WHERE id = $2 RETURNING id" ,
789+ & [ & description, & id] ,
790+ )
791+ . await ?
792+ . get :: < _ , i32 > ( 0 ) ;
793+
794+ Ok ( Sector ( sector_id) )
795+ }
796+
719797 async fn move_climb (
720798 & self ,
721799 ctx : & Context < ' _ > ,
0 commit comments