Skip to content

Commit 511e8f2

Browse files
fix(GraphQL): only mark types as nonNull if they are unconditional #778
Fields that are conditionally required need to be nullable as they are only required if the fields conditions are met. Marking them as nonNull types will result in schema errors if the condition is not met for a specific object.
1 parent d943a4e commit 511e8f2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ class GraphQLSchema extends Schema {
127127
$type = Type::listOf($type);
128128
}
129129

130-
# Make this field non-nullable if it is required
131-
if ($field->required and !$ignore_required) {
130+
# Make this field non-nullable if it is required and unconditional
131+
if ($field->required and !$field->conditions and !$ignore_required) {
132132
$type = Type::nonNull($type);
133133
}
134134

0 commit comments

Comments
 (0)