From 8f716fc65dd256561eaf85ced983ff1a1c3411b1 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Mon, 10 Feb 2025 21:27:52 -0700 Subject: [PATCH] fix(graphql): ensure correct object types are set in schema #623 --- .../files/usr/local/pkg/RESTAPI/Schemas/GraphQLSchema.inc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Schemas/GraphQLSchema.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Schemas/GraphQLSchema.inc index 2662cbcb..ae76bc2d 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Schemas/GraphQLSchema.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Schemas/GraphQLSchema.inc @@ -216,7 +216,12 @@ class GraphQLSchema extends Schema { foreach ($model->get_fields() as $field) { # For NestedModelFields, ensure we pass the Type for the nested Model if ($model->$field instanceof NestedModelField) { - $nested_model_type = $this->get_model_input_object_type($model->$field->model_class); + if ($input) { + $nested_model_type = $this->get_model_input_object_type($model->$field->model_class); + } + else { + $nested_model_type = $this->get_model_object_type($model->$field->model_class); + } $fields[$field]['type'] = $this->field_to_type(field: $model->$field, type: $nested_model_type); $fields[$field]['description'] = $model->$field->help_text; continue;