Skip to content

Commit d8e68bc

Browse files
fix: adjust what criteria is required for sorting
1 parent 1e35c1b commit d8e68bc

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Model.inc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,22 +214,22 @@ class Model {
214214
public int|null $placement = null;
215215

216216
/**
217-
* @var int|null $sort_order
217+
* @var int $sort_order
218218
* For $many enabled Models, this property can be used to set the PHP sort option used when writing Model objects to
219219
* config. This property is only applicable if the $sort_by_field property is also defined. This property only applies
220220
* to Models with a $config_path defined. For valid value options for this property, refer to:
221221
* https://www.php.net/manual/en/function.array-multisort.php
222222
*/
223-
public int|null $sort_order = null;
223+
public int $sort_order = SORT_ASC;
224224

225225
/**
226-
* @var int|null $sort_flags
226+
* @var int $sort_flags
227227
* For $many enabled Models, this property can be used to set the PHP sort flags used when writing Model objects to
228228
* config. This property is only applicable if the $sort_by_field property is also defined. This property only applies
229229
* to Models with a $config_path defined. For valid value options for this property, refer to:
230230
* https://www.php.net/manual/en/function.array-multisort.php
231231
*/
232-
public int|null $sort_flags = null;
232+
public int $sort_flags = SORT_REGULAR;
233233

234234
/**
235235
* @var array|null $sort_by
@@ -1698,8 +1698,8 @@ class Model {
16981698
* internal objects must be written in a specific order.
16991699
*/
17001700
protected function sort(): void {
1701-
# Do not sort if there is no `sort_order` or `sort_by` set
1702-
if (!$this->sort_order or !$this->sort_by) {
1701+
# Do not sort if there is no `sort_by` fields set
1702+
if (!$this->sort_by) {
17031703
return;
17041704
}
17051705

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Schemas/GraphQLSchema.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class GraphQLSchema extends Schema {
216216
foreach ($model->get_fields() as $field) {
217217
# For NestedModelFields, ensure we pass the Type for the nested Model
218218
if ($model->$field instanceof NestedModelField) {
219-
$nested_model_type = $this->get_model_object_type($model->$field->model_class);
219+
$nested_model_type = $this->get_model_input_object_type($model->$field->model_class);
220220
$fields[$field]['type'] = $this->field_to_type(field: $model->$field, type: $nested_model_type);
221221
$fields[$field]['description'] = $model->$field->help_text;
222222
continue;

0 commit comments

Comments
 (0)