@@ -55,11 +55,11 @@ public static function register_type(): void {
5555 ],
5656 'args ' => [
5757 'flat ' => [
58- 'description ' => __ ( 'Returns the list of blocks as a flat list if true ' , 'wp-graphql-content-blocks ' ),
58+ 'description ' => static fn () => __ ( 'Returns the list of blocks as a flat list if true ' , 'wp-graphql-content-blocks ' ),
5959 'type ' => 'Boolean ' ,
6060 ],
6161 ],
62- 'description ' => __ ( 'List of editor blocks ' , 'wp-graphql-content-blocks ' ),
62+ 'description ' => static fn () => __ ( 'List of editor blocks ' , 'wp-graphql-content-blocks ' ),
6363 'resolve ' => static function ( $ node , $ args ) {
6464 return ContentBlocksResolver::resolve_content_blocks ( $ node , $ args );
6565 },
@@ -72,118 +72,91 @@ public static function register_type(): void {
7272 // Register the EditorBlock Interface
7373 register_graphql_interface_type (
7474 'EditorBlock ' ,
75- [
76- ' eagerlyLoadType ' => true ,
77- ' description ' => static fn () => __ ( ' Blocks that can be edited to create content and layouts ' , ' wp-graphql-content-blocks ' ),
78- ' fields ' => [
79- // @TODO - Remove when WPGraphQL min version is 2.3.0
80- 'clientId ' => WPGraphQLRegisterConfig:: resolve_graphql_config (
81- [
75+ // @TODO - Remove when WPGraphQL min version is 2.3.0
76+ WPGraphQLRegisterConfig:: resolve_graphql_config (
77+ [
78+ ' eagerlyLoadType ' => true ,
79+ ' description ' => static fn () => __ ( ' Blocks that can be edited to create content and layouts ' , ' wp-graphql-content-blocks ' ),
80+ 'fields ' => [
81+ ' clientId ' => [
8282 'type ' => 'String ' ,
83- 'description ' => __ ( 'The id of the Block ' , 'wp-graphql-content-blocks ' ),
83+ 'description ' => static fn () => __ ( 'The id of the Block ' , 'wp-graphql-content-blocks ' ),
8484 'resolve ' => static function ( $ block ) {
8585 return isset ( $ block ['clientId ' ] ) ? $ block ['clientId ' ] : uniqid ();
8686 },
87- ]
88- ),
89- // @TODO - Remove when WPGraphQL min version is 2.3.0
90- 'parentClientId ' => WPGraphQLRegisterConfig::resolve_graphql_config (
91- [
87+ ],
88+ 'parentClientId ' => [
9289 'type ' => 'String ' ,
93- 'description ' => __ ( 'The parent id of the Block ' , 'wp-graphql-content-blocks ' ),
90+ 'description ' => static fn () => __ ( 'The parent id of the Block ' , 'wp-graphql-content-blocks ' ),
9491 'resolve ' => static function ( $ block ) {
9592 return isset ( $ block ['parentClientId ' ] ) ? $ block ['parentClientId ' ] : null ;
9693 },
97- ]
98- ),
99- // @TODO - Remove when WPGraphQL min version is 2.3.0
100- 'name ' => WPGraphQLRegisterConfig::resolve_graphql_config (
101- [
94+ ],
95+ 'name ' => [
10296 'type ' => 'String ' ,
103- 'description ' => __ ( 'The name of the Block ' , 'wp-graphql-content-blocks ' ),
104- ]
105- ),
106- // @TODO - Remove when WPGraphQL min version is 2.3.0
107- 'blockEditorCategoryName ' => WPGraphQLRegisterConfig::resolve_graphql_config (
108- [
97+ 'description ' => static fn () => __ ( 'The name of the Block ' , 'wp-graphql-content-blocks ' ),
98+ ],
99+ 'blockEditorCategoryName ' => [
109100 'type ' => 'String ' ,
110- 'description ' => __ ( 'The name of the category the Block belongs to ' , 'wp-graphql-content-blocks ' ),
101+ 'description ' => static fn () => __ ( 'The name of the category the Block belongs to ' , 'wp-graphql-content-blocks ' ),
111102 'resolve ' => static function ( $ block ) {
112103 return isset ( self ::get_block ( $ block )->category ) ? self ::get_block ( $ block )->category : null ;
113104 },
114- ]
115- ),
116- // @TODO - Remove when WPGraphQL min version is 2.3.0
117- 'isDynamic ' => WPGraphQLRegisterConfig::resolve_graphql_config (
118- [
105+ ],
106+ 'isDynamic ' => [
119107 'type ' => [ 'non_null ' => 'Boolean ' ],
120- 'description ' => __ ( 'Whether the block is Dynamic (server rendered) ' , 'wp-graphql-content-blocks ' ),
108+ 'description ' => static fn () => __ ( 'Whether the block is Dynamic (server rendered) ' , 'wp-graphql-content-blocks ' ),
121109 'resolve ' => static function ( $ block ) {
122110 return isset ( self ::get_block ( $ block )->render_callback );
123111 },
124- ]
125- ),
126- // @TODO - Remove when WPGraphQL min version is 2.3.0
127- 'apiVersion ' => WPGraphQLRegisterConfig::resolve_graphql_config (
128- [
112+ ],
113+ 'apiVersion ' => [
129114 'type ' => 'Integer ' ,
130- 'description ' => __ ( 'The API version of the Gutenberg Block ' , 'wp-graphql-content-blocks ' ),
115+ 'description ' => static fn () => __ ( 'The API version of the Gutenberg Block ' , 'wp-graphql-content-blocks ' ),
131116 'resolve ' => static function ( $ block ) {
132117 return isset ( self ::get_block ( $ block )->api_version ) && absint ( self ::get_block ( $ block )->api_version ) ? absint ( self ::get_block ( $ block )->api_version ) : 2 ;
133118 },
134- ]
135- ),
136- // @TODO - Remove when WPGraphQL min version is 2.3.0
137- 'innerBlocks ' => WPGraphQLRegisterConfig::resolve_graphql_config (
138- [
119+ ],
120+ 'innerBlocks ' => [
139121 'type ' => [
140122 'list_of ' => 'EditorBlock ' ,
141123 ],
142- 'description ' => __ ( 'The inner blocks of the Block ' , 'wp-graphql-content-blocks ' ),
124+ 'description ' => static fn () => __ ( 'The inner blocks of the Block ' , 'wp-graphql-content-blocks ' ),
143125 'resolve ' => static function ( $ block ) {
144126 return isset ( $ block ['innerBlocks ' ] ) && is_array ( $ block ['innerBlocks ' ] ) ? $ block ['innerBlocks ' ] : [];
145127 },
146- ]
147- ),
148- // @TODO - Remove when WPGraphQL min version is 2.3.0
149- 'cssClassNames ' => WPGraphQLRegisterConfig::resolve_graphql_config (
150- [
128+ ],
129+ 'cssClassNames ' => [
151130 'type ' => [ 'list_of ' => 'String ' ],
152- 'description ' => __ ( 'CSS Classnames to apply to the block ' , 'wp-graphql-content-blocks ' ),
131+ 'description ' => static fn () => __ ( 'CSS Classnames to apply to the block ' , 'wp-graphql-content-blocks ' ),
153132 'resolve ' => static function ( $ block ) {
154133 if ( isset ( $ block ['attrs ' ]['className ' ] ) ) {
155134 return explode ( ' ' , $ block ['attrs ' ]['className ' ] );
156135 }
157136
158137 return null ;
159138 },
160- ]
161- ),
162- // @TODO - Remove when WPGraphQL min version is 2.3.0
163- 'renderedHtml ' => WPGraphQLRegisterConfig::resolve_graphql_config (
164- [
139+ ],
140+ 'renderedHtml ' => [
165141 'type ' => 'String ' ,
166- 'description ' => __ ( 'The rendered HTML for the block ' , 'wp-graphql-content-blocks ' ),
142+ 'description ' => static fn () => __ ( 'The rendered HTML for the block ' , 'wp-graphql-content-blocks ' ),
167143 'resolve ' => static function ( $ block ) {
168144 return WPGraphQLHelpers::get_rendered_block ( $ block );
169145 },
170- ]
171- ),
172- // @TODO - Remove when WPGraphQL min version is 2.3.0
173- 'type ' => WPGraphQLRegisterConfig::resolve_graphql_config (
174- [
146+ ],
147+ 'type ' => [
175148 'type ' => 'String ' ,
176- 'description ' => __ ( 'The (GraphQL) type of the block ' , 'wp-graphql-content-blocks ' ),
149+ 'description ' => static fn () => __ ( 'The (GraphQL) type of the block ' , 'wp-graphql-content-blocks ' ),
177150 'resolve ' => static function ( $ block ) {
178151 return WPGraphQLHelpers::get_type_name_for_block ( $ block ['blockName ' ] ?? null );
179152 },
180- ]
181- ) ,
182- ],
183- ' resolveType ' => static function ( $ block ) {
184- return WPGraphQLHelpers:: get_type_name_for_block ( $ block [ ' blockName ' ] ?? null );
185- },
186- ]
153+ ],
154+ ] ,
155+ ' resolveType ' => static function ( $ block ) {
156+ return WPGraphQLHelpers:: get_type_name_for_block ( $ block[ ' blockName ' ] ?? null );
157+ },
158+ ]
159+ )
187160 );
188161 }
189162}
0 commit comments