Merge pull request #358 from Aaron1011/fix/object-raw-ident
Strip `r#` prefix when constructing getter ident
This commit is contained in:
commit
383456f007
|
@ -374,7 +374,10 @@ pub fn generate(
|
|||
}
|
||||
None => quote! { ::std::option::Option::None },
|
||||
};
|
||||
let param_getter_name = get_param_getter_ident(&ident.ident.to_string());
|
||||
// We're generating a new identifier,
|
||||
// so remove the 'r#` prefix if present
|
||||
let param_getter_name =
|
||||
get_param_getter_ident(&ident.ident.unraw().to_string());
|
||||
get_params.push(quote! {
|
||||
#[allow(non_snake_case)]
|
||||
let #param_getter_name = || -> #crate_name::ServerResult<#ty> { ctx.param_value(#name, #default) };
|
||||
|
|
|
@ -11,24 +11,26 @@ pub async fn test_input_value_custom_error() {
|
|||
|
||||
#[derive(SimpleObject)]
|
||||
struct MyObject {
|
||||
r#i32: i32,
|
||||
r#match: i32,
|
||||
}
|
||||
|
||||
#[derive(InputObject)]
|
||||
struct MyInputObject {
|
||||
r#i32: i32,
|
||||
r#match: i32,
|
||||
}
|
||||
|
||||
struct Query;
|
||||
|
||||
#[Object]
|
||||
impl Query {
|
||||
async fn r#type(&self, r#i32: i32) -> i32 {
|
||||
r#i32
|
||||
async fn r#type(&self, r#match: i32) -> i32 {
|
||||
r#match
|
||||
}
|
||||
|
||||
async fn obj(&self, obj: MyInputObject) -> MyObject {
|
||||
MyObject { r#i32: obj.r#i32 }
|
||||
MyObject {
|
||||
r#match: obj.r#match,
|
||||
}
|
||||
}
|
||||
|
||||
async fn enum_value(&self, value: MyEnum) -> MyEnum {
|
||||
|
@ -48,15 +50,15 @@ pub async fn test_input_value_custom_error() {
|
|||
let schema = Schema::new(Query, EmptyMutation, SubscriptionRoot);
|
||||
let query = r#"
|
||||
{
|
||||
type(i32: 99)
|
||||
obj(obj: { i32: 88} ) { i32 }
|
||||
type(match: 99)
|
||||
obj(obj: { match: 88} ) { match }
|
||||
enumValue(value: TYPE)
|
||||
}"#;
|
||||
assert_eq!(
|
||||
schema.execute(query).await.into_result().unwrap().data,
|
||||
value!({
|
||||
"type": 99,
|
||||
"obj": { "i32": 88 },
|
||||
"obj": { "match": 88 },
|
||||
"enumValue": "TYPE",
|
||||
})
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user