From 4147f673d313f1b39f8e3a5565e25ceb9ca6e3d1 Mon Sep 17 00:00:00 2001 From: Raphael Darley Date: Mon, 16 Sep 2024 14:23:22 +0100 Subject: [PATCH] add descriptions to graphql (#4776) Co-authored-by: Tobie Morgan Hitchcock --- core/src/gql/schema.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/src/gql/schema.rs b/core/src/gql/schema.rs index 8d127ab4..576f280e 100644 --- a/core/src/gql/schema.rs +++ b/core/src/gql/schema.rs @@ -103,8 +103,16 @@ pub async fn generate_schema( let table_orderable_name = format!("_orderable_{tb_name}"); let mut table_orderable = Enum::new(&table_orderable_name).item("id"); + table_orderable = table_orderable.description(format!( + "Generated from `{}` the fields which a query can be ordered by", + tb.name + )); let table_order_name = format!("_order_{tb_name}"); let table_order = InputObject::new(&table_order_name) + .description(format!( + "Generated from `{}` an object representing a query ordering", + tb.name + )) .field(InputValue::new("asc", TypeRef::named(&table_orderable_name))) .field(InputValue::new("desc", TypeRef::named(&table_orderable_name))) .field(InputValue::new("then", TypeRef::named(&table_order_name))); @@ -251,6 +259,7 @@ pub async fn generate_schema( }) }, ) + .description(format!("Generated from table `{}`{}\nallows querying a table with filters", tb.name, if let Some(ref c) = &tb.comment {format!("\n{c}")} else {"".to_string()})) .argument(limit_input!()) .argument(start_input!()) .argument(InputValue::new("order", TypeRef::named(&table_order_name))) @@ -297,6 +306,15 @@ pub async fn generate_schema( }) }, ) + .description(format!( + "Generated from table `{}`{}\nallows querying a single record in a table by id", + tb.name, + if let Some(ref c) = &tb.comment { + format!("\n{c}") + } else { + "".to_string() + } + )) .argument(id_input!()), ); @@ -381,6 +399,7 @@ pub async fn generate_schema( } }) }) + .description("allows fetching arbitrary records".to_string()) .argument(id_input!()), );