File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -388,4 +388,17 @@ class APIModelsGraphQLTestCase extends TestCase {
388388 },
389389 );
390390 }
391+
392+ /**
393+ * Ensure we can query for model fields that are conditionally required. Regression test for #778
394+ */
395+ public function test_query_conditionally_required_field (): void {
396+ # Query for interfaces including conditionally required fields and ensure no errors are returned.
397+ $ graphql = new GraphQL (
398+ query: 'query {queryInterfaces {id ipaddr subnet descr typev4 track6_interface}} ' ,
399+ client: $ this ->auth ,
400+ );
401+ $ graphql ->create ();
402+ $ this ->assert_is_empty ($ graphql ->result ->value ['errors ' ] ?? []);
403+ }
391404}
You can’t perform that action at this time.
0 commit comments