Fixes #1004
This commit is contained in:
parent
bd1262df7f
commit
0eefc3932b
|
@ -102,7 +102,7 @@ pub fn generate(object_args: &args::InputObject) -> GeneratorResult<TokenStream>
|
|||
|
||||
schema_fields.push(quote! {
|
||||
#crate_name::static_assertions::assert_impl_one!(#ty: #crate_name::InputObjectType);
|
||||
#ty::create_type_info(registry);
|
||||
<#ty as #crate_name::InputType>::create_type_info(registry);
|
||||
if let #crate_name::registry::MetaType::InputObject { input_fields, .. } =
|
||||
registry.create_fake_input_type::<#ty>() {
|
||||
fields.extend(input_fields);
|
||||
|
|
|
@ -180,7 +180,7 @@ pub fn generate(object_args: &args::SimpleObject) -> GeneratorResult<TokenStream
|
|||
});
|
||||
} else {
|
||||
schema_fields.push(quote! {
|
||||
#ty::create_type_info(registry);
|
||||
<#ty as #crate_name::OutputType>::create_type_info(registry);
|
||||
if let #crate_name::registry::MetaType::Object { fields: obj_fields, .. } =
|
||||
registry.create_fake_output_type::<#ty>() {
|
||||
fields.extend(obj_fields);
|
||||
|
|
|
@ -449,6 +449,51 @@ pub fn test_both_input_output_with_same_name() {
|
|||
Schema::new(Query, EmptyMutation, EmptySubscription);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
pub async fn test_both_input_output_flatten() {
|
||||
#[derive(SimpleObject, InputObject)]
|
||||
#[graphql(input_name = "ABCInput")]
|
||||
#[graphql(name = "ABC")]
|
||||
struct ABC {
|
||||
a: i32,
|
||||
#[graphql(flatten)]
|
||||
bc: BC,
|
||||
}
|
||||
|
||||
#[derive(SimpleObject, InputObject)]
|
||||
#[graphql(input_name = "BCInput")]
|
||||
struct BC {
|
||||
b: i32,
|
||||
c: i32,
|
||||
}
|
||||
|
||||
struct Query;
|
||||
|
||||
#[Object]
|
||||
impl Query {
|
||||
async fn obj(&self, input: ABC) -> ABC {
|
||||
input
|
||||
}
|
||||
}
|
||||
|
||||
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
|
||||
assert_eq!(
|
||||
schema
|
||||
.execute("{ obj(input: { a: 1, b: 2, c: 3 }) { a b c } }")
|
||||
.await
|
||||
.into_result()
|
||||
.unwrap()
|
||||
.data,
|
||||
value!({
|
||||
"obj": {
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
pub async fn test_skip_input() {
|
||||
#[derive(SimpleObject, InputObject)]
|
||||
|
|
Loading…
Reference in New Issue
Block a user