add descriptions to graphql (#4776)

Co-authored-by: Tobie Morgan Hitchcock <tobie@surrealdb.com>
This commit is contained in:
Raphael Darley 2024-09-16 14:23:22 +01:00 committed by GitHub
parent 9cfdd34fc0
commit 4147f673d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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!()),
);