Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

Commit bc20b9d

Browse files
authored
Merge pull request #94 from jasonbahl/bug/#91-flex-field-with-no-layout-causes-issues
#91 - Don't add flex fields to the Schema if there are no layouts configured
2 parents b15c191 + 3ede9a7 commit bc20b9d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/class-config.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use WPGraphQL\Model\Post;
1515
use WPGraphQL\Model\Term;
1616
use WPGraphQL\Model\User;
17-
use WPGraphQL\Types;
1817

1918
/**
2019
* Config class.
@@ -777,12 +776,21 @@ protected function register_graphql_field( $type_name, $field_name, $config ) {
777776

778777
$flex_field_layout_name = ! empty( $layout['name'] ) ? ucfirst( self::camel_case( $layout['name'] ) ) : null;
779778
$flex_field_layout_name = ! empty( $flex_field_layout_name ) ? $field_type_name . '_' . $flex_field_layout_name : null;
779+
780+
/**
781+
* If there are no layouts defined for the Flex Field
782+
*/
783+
if ( empty( $flex_field_layout_name ) ) {
784+
continue;
785+
}
786+
780787
$layout_type = $this->type_registry->get_type( $flex_field_layout_name );
781788

782789
if ( $layout_type ) {
783790
$union_types[ $layout['name'] ] = $layout_type;
784791
} else {
785792

793+
786794
register_graphql_object_type( $flex_field_layout_name, [
787795
'description' => __( 'Group within the flex field', 'wp-graphql-acf' ),
788796
'fields' => [

0 commit comments

Comments
 (0)