add descriptions to graphql (#4776)
Co-authored-by: Tobie Morgan Hitchcock <tobie@surrealdb.com>
This commit is contained in:
parent
9cfdd34fc0
commit
4147f673d3
1 changed files with 19 additions and 0 deletions
|
@ -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!()),
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue