Fixed #attribute not working on the InputObject fields.
This commit is contained in:
parent
a813ce72a3
commit
03e1604f0b
|
@ -20,7 +20,13 @@ pub fn generate(object_args: &args::InputObject, input: &DeriveInput) -> Result<
|
|||
let vis = &field.vis;
|
||||
let ty = &field.ty;
|
||||
let ident = &field.ident;
|
||||
let attrs = field
|
||||
.attrs
|
||||
.iter()
|
||||
.filter(|attr| !attr.path.is_ident("field"))
|
||||
.collect::<Vec<_>>();
|
||||
struct_fields.push(quote! {
|
||||
#(#attrs)*
|
||||
#vis #ident: #ty
|
||||
});
|
||||
}
|
||||
|
|
|
@ -93,3 +93,21 @@ pub async fn test_input_object_default_value() {
|
|||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
pub async fn test_inputobject_derive_and_item_attributes() {
|
||||
use serde::Deserialize;
|
||||
|
||||
#[async_graphql::InputObject]
|
||||
#[derive(Deserialize, PartialEq, Debug)]
|
||||
struct MyInputObject {
|
||||
#[field]
|
||||
#[serde(alias = "other")]
|
||||
real: i32,
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
serde_json::from_str::<MyInputObject>(r#"{ "other" : 100 }"#).unwrap(),
|
||||
MyInputObject { real: 100 }
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user