Skip to content

Commit

Permalink
Merge pull request #85 from cristobalbahe/main
Browse files Browse the repository at this point in the history
Fix TermNodes returning null when not array and fix type being set to generic TermNode in Taxonomy field
  • Loading branch information
jasonbahl authored Sep 11, 2023
2 parents 39a9243 + 5a82c6a commit 3b402e0
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/FieldType/Taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ public static function register_field_type(): void {
'resolve' => static function ( $root, $args, AppContext $context, $info ) use ( $field_config ) {
$value = $field_config->resolve_field( $root, $args, $context, $info );

if ( empty( $value ) || ! is_array( $value ) ) {
if ( empty( $value ) ) {
return null;
}

$value = array_map(
static function ( $id ) {
return absint( $id );
},
$value
);
if ( is_array( $value ) ) {
$value = array_map(
static function ( $id ) {
return absint( $id );
},
$value
);
}

$resolver = new TermObjectConnectionResolver( $root, $args, $context, $info );
return $resolver
Expand Down

0 comments on commit 3b402e0

Please sign in to comment.