diff --git a/src/class-config.php b/src/class-config.php index 927f2b3..08c3c4b 100644 --- a/src/class-config.php +++ b/src/class-config.php @@ -689,12 +689,14 @@ protected function register_graphql_field( string $type_name, string $field_name $post_object = get_post( $post_id ); if ( $post_object instanceof \WP_Post ) { $post_model = new Post( $post_object ); - $relationship[] = $post_model; + if ( 'private' != $post_model->get_visibility() ) { + $relationship[] = $post_model; + } } } } - return isset( $value ) ? $relationship : null; + return empty( $relationship ) ? null : $relationship; }, ]; diff --git a/tests/wpunit/ExplicitOptionsTest.php b/tests/wpunit/ExplicitOptionsTest.php index 4ddfc78..0c255aa 100644 --- a/tests/wpunit/ExplicitOptionsTest.php +++ b/tests/wpunit/ExplicitOptionsTest.php @@ -89,6 +89,7 @@ public function testExplicitOptions() { 'show_in_graphql' => true, 'graphql_single_name' => 'acfCpt', 'graphql_plural_name' => 'acfCpts', + 'public' => true, ] ); @@ -148,7 +149,7 @@ public function testExplicitOptions() { ] ); - $expected_text_3 = 'test value2'; + $expected_text_3 = 'test value3'; update_field( 'acf_text_field', $expected_text_3, $cpt_id ); // post assert validation. diff --git a/tests/wpunit/PostObjectFieldsTest.php b/tests/wpunit/PostObjectFieldsTest.php index 13d8d0e..20e3816 100644 --- a/tests/wpunit/PostObjectFieldsTest.php +++ b/tests/wpunit/PostObjectFieldsTest.php @@ -1213,8 +1213,8 @@ public function testQueryMultipleSelectFieldWithNoValueSet() { public function testQueryFieldOnCustomPostType() { register_post_type( 'acf_test', [ - 'show_ui' => true, - 'show_in_graphql' => 'true', + 'public' => true, + 'show_in_graphql' => 'true', 'graphql_single_name' => 'acfTest', 'graphql_plural_name' => 'acfTests' ] );