From 5e1d2cf5061819da31992942de164286e5e2497b Mon Sep 17 00:00:00 2001 From: Daniel Chambers Date: Wed, 27 Mar 2024 18:08:50 +1100 Subject: [PATCH] Fix missing descriptions on GraphQL input object types (#409) Fixes descriptions defined on `ObjectType`s and their fields in metadata not showing up when that type is expressed as an input object type in GraphQL. V3_GIT_ORIGIN_REV_ID: de5cb2d545441fdebdf85fa84c90e9f0a4cbaac7 --- v3/crates/engine/src/schema/types/input_type.rs | 9 +++++++-- v3/crates/engine/tests/execute/description/expected.json | 6 +++--- v3/crates/engine/tests/execute/description/metadata.json | 3 +++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/v3/crates/engine/src/schema/types/input_type.rs b/v3/crates/engine/src/schema/types/input_type.rs index cf56d94883c..673684304ba 100644 --- a/v3/crates/engine/src/schema/types/input_type.rs +++ b/v3/crates/engine/src/schema/types/input_type.rs @@ -116,7 +116,7 @@ fn input_object_type_input_fields( let input_field = gql_schema::InputField::new( graphql_field_name.clone(), - None, // Description + field_definition.description.clone(), types::Annotation::Input(types::InputAnnotation::InputObjectField { field_name: field_name.clone(), field_type: field_definition.field_type.clone(), @@ -162,6 +162,11 @@ pub fn input_object_type_schema( input_object_type_input_fields(gds, builder, &object_type_representation.fields)?; Ok(gql_schema::TypeInfo::InputObject( - gql_schema::InputObject::new(graphql_type_name, None, input_fields, Vec::new()), + gql_schema::InputObject::new( + graphql_type_name, + object_type_representation.description.clone(), + input_fields, + Vec::new(), + ), )) } diff --git a/v3/crates/engine/tests/execute/description/expected.json b/v3/crates/engine/tests/execute/description/expected.json index c8c430c98ac..3c30a4fc074 100644 --- a/v3/crates/engine/tests/execute/description/expected.json +++ b/v3/crates/engine/tests/execute/description/expected.json @@ -123,16 +123,16 @@ }, { "name": "NameFilterOpaqueSurname", - "description": null, + "description": "Some description for custom input object type", "fields": null, "inputFields": [ { "name": "first_name", - "description": null + "description": "Some description of first name" }, { "name": "surname", - "description": null + "description": "Some description of last name" } ] }, diff --git a/v3/crates/engine/tests/execute/description/metadata.json b/v3/crates/engine/tests/execute/description/metadata.json index 181954debc2..e417b962053 100644 --- a/v3/crates/engine/tests/execute/description/metadata.json +++ b/v3/crates/engine/tests/execute/description/metadata.json @@ -228,13 +228,16 @@ "version": "v1", "definition": { "name": "NameFilterOpaqueSurname", + "description": "Some description for custom input object type", "fields": [ { "name": "first_name", + "description": "Some description of first name", "type": "String" }, { "name": "surname", + "description": "Some description of last name", "type": "Opaque" } ],