Repository navigation
Replies: 1 comment
|
No macro is needed: camelCase is Seaography's default. Field and mutation names are chosen when Seaography is compiled, by its Cargo features. The default If you can't drop that feature, or want to control the names yourself, they all come from use heck::ToLowerCamelCase; // heck = "0.5"
use seaography::{
lazy_static, Builder, BuilderContext, EntityCreateBatchMutationConfig,
EntityCreateOneMutationConfig, EntityDeleteMutationConfig, EntityObjectConfig,
EntityQueryFieldConfig, EntityUpdateMutationConfig,
};
lazy_static::lazy_static! {
static ref CONTEXT: BuilderContext = BuilderContext {
// field names: unit_price -> unitPrice
entity_object: EntityObjectConfig {
column_name: Box::new(|_entity, column| column.to_lower_camel_case()),
..Default::default()
},
// query names (cart_item -> cartItem) and the orderBy argument
entity_query_field: EntityQueryFieldConfig {
type_name: Box::new(|object| object.to_lower_camel_case()),
order_by: "orderBy".into(),
..Default::default()
},
// mutation names: cartItemCreateOne, cartItemCreateBatch, cartItemUpdate, cartItemDelete
entity_create_one_mutation: EntityCreateOneMutationConfig {
mutation_suffix: "CreateOne".into(),
..Default::default()
},
entity_create_batch_mutation: EntityCreateBatchMutationConfig {
mutation_suffix: "CreateBatch".into(),
..Default::default()
},
entity_update_mutation: EntityUpdateMutationConfig {
mutation_suffix: "Update".into(),
..Default::default()
},
entity_delete_mutation: EntityDeleteMutationConfig {
mutation_suffix: "Delete".into(),
..Default::default()
},
..Default::default()
};
}
// then, as in the generated query_root.rs:
// let mut builder = Builder::new(&CONTEXT, database.clone());I checked this with seaography 1.1.4 and sea-orm 1.1 (SQLite) by printing the SDL for an entity |
Uh oh!
There was an error while loading. Please reload this page.
Is there a macro or trait implementation that'll allow my mutation names and fields to be
camelCaseAll reactions