Skip to content

Commit d69ba7a

Browse files
committed
- update test to merge args in the resolver instead of assuming set_query_arg will merge
1 parent 3ce7c3d commit d69ba7a

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

tests/wpunit/PostObjectConnectionQueriesTest.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,17 +1901,15 @@ public function testConnectionArgsAsArrayAreMergedProperly() {
19011901
],
19021902
'resolve' => function( \WPGraphQL\Model\Term $term, $args, $context, $info ) use ( &$query_args ) {
19031903
$resolver = new \WPGraphQL\Data\Connection\PostObjectConnectionResolver( $term, $args, $context, $info, 'post' );
1904-
$resolver->set_query_arg(
1905-
'tax_query',
1906-
[
1907-
[
1908-
'taxonomy' => $term->taxonomyName,
1909-
'terms' => [ $term->term_id ],
1910-
'field' => 'term_id',
1911-
'include_children' => false,
1912-
],
1913-
]
1914-
);
1904+
$current_args = $resolver->get_query_args();
1905+
$tax_query = $current_args['tax_query'] ?? [];
1906+
$tax_query[] = [
1907+
'taxonomy' => $term->taxonomyName,
1908+
'terms' => [ $term->term_id ],
1909+
'field' => 'term_id',
1910+
'include_children' => false,
1911+
];
1912+
$resolver->set_query_arg( 'tax_query', $tax_query );
19151913
$query_args = $resolver->get_query_args();
19161914
return $resolver->get_connection();
19171915
},

0 commit comments

Comments
 (0)