Closed andrejohansson closed 4 years ago
I do not think supporting raw identifiers is the right way here. The better way is to provide corresponding attributes to rename the fields, as this is useful in more situations and allows a finer control.
Let's look at the different cases:
For diesel's table macro there is already the #[sql_name = "some_name"]
attribute. So you could write your example table as
table! {
options (id) {
id -> Int4,
label -> Varchar,
values -> Array<Text>,
#[sql_name = "type"]
tpe -> crate::domain::option::model::OptionTypeEnumMapping,
}
}
See the corresponding documentation here
For WundergraphDerive
there is the #[column_name = "foo"]
attribute that let's you specify the corresponding column name (that one that is used in the diesel table!
macro, so tpe
in this example. You can then set the corresponding graphql name via the #[wundergraph(graphql_name = "Foo")]
. See the corresponding documentation here
For the enum there is #[graphql(name = "CustomVariantName")]
for setting a custom
variant string for graphql. I think juniper uses the same attribute here, so this works for both, the WundergraphValue
and the GraphQLEnum
. I'm not sure how DbEnum
handles this case, as I'm not using this crate. (I normally just implement FromSql
/ToSql
by myself.) Documentation for WundergraphValue
and for GraphQLEnum
Hello, it´s me again! :-)
Is there any way to support raw identifiers?
It might be a corner case, but sometimetimes it´s necessary to use the notation if you have naming collisions.
This gives the error:
This example is exaggerated but I do think there are valid uses if you want to keep a clean naming structure someties.
Is this supported already? Am I posting this in the right repo or should I post to juniper/diesel instead?