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
This commit is contained in:
Daniel Chambers 2024-03-27 18:08:50 +11:00 committed by hasura-bot
parent 13d36900f7
commit 5e1d2cf506
3 changed files with 13 additions and 5 deletions

View File

@ -116,7 +116,7 @@ fn input_object_type_input_fields(
let input_field = gql_schema::InputField::new( let input_field = gql_schema::InputField::new(
graphql_field_name.clone(), graphql_field_name.clone(),
None, // Description field_definition.description.clone(),
types::Annotation::Input(types::InputAnnotation::InputObjectField { types::Annotation::Input(types::InputAnnotation::InputObjectField {
field_name: field_name.clone(), field_name: field_name.clone(),
field_type: field_definition.field_type.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)?; input_object_type_input_fields(gds, builder, &object_type_representation.fields)?;
Ok(gql_schema::TypeInfo::InputObject( 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(),
),
)) ))
} }

View File

@ -123,16 +123,16 @@
}, },
{ {
"name": "NameFilterOpaqueSurname", "name": "NameFilterOpaqueSurname",
"description": null, "description": "Some description for custom input object type",
"fields": null, "fields": null,
"inputFields": [ "inputFields": [
{ {
"name": "first_name", "name": "first_name",
"description": null "description": "Some description of first name"
}, },
{ {
"name": "surname", "name": "surname",
"description": null "description": "Some description of last name"
} }
] ]
}, },

View File

@ -228,13 +228,16 @@
"version": "v1", "version": "v1",
"definition": { "definition": {
"name": "NameFilterOpaqueSurname", "name": "NameFilterOpaqueSurname",
"description": "Some description for custom input object type",
"fields": [ "fields": [
{ {
"name": "first_name", "name": "first_name",
"description": "Some description of first name",
"type": "String" "type": "String"
}, },
{ {
"name": "surname", "name": "surname",
"description": "Some description of last name",
"type": "Opaque" "type": "Opaque"
} }
], ],