Skip to content

Commit 7bd3d9b

Browse files
committed
- add wpgraphql/acf/graphql_field_type/resolve_type filter to allow specific types of ACF Fields to return a different GraphQL Type based on certain config settings
1 parent 31c56c6 commit 7bd3d9b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/AcfGraphQLFieldType.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,18 @@ public function get_resolver( $root, array $args, AppContext $context, ResolveIn
273273
* @return array|string
274274
*/
275275
public function get_resolve_type( FieldConfig $field_config ) {
276+
276277
$acf_field = $field_config->get_acf_field();
277278

279+
/**
280+
* If external code has filtered this to return anything other than null, use the filtered type instead of the default
281+
*/
282+
$pre_get_resolve_type = apply_filters( 'wpgraphql/acf/graphql_field_type/resolve_type', null, $field_config, $acf_field );
283+
284+
if ( null !== $pre_get_resolve_type ) {
285+
return $pre_get_resolve_type;
286+
}
287+
278288
$resolve_type = 'String';
279289

280290
if ( isset( $acf_field['graphql_resolve_type'] ) ) {

0 commit comments

Comments
 (0)