Skip to content

Commit 47fe8ab

Browse files
committed
dev: revert last, and use taxonomy on query_vars
1 parent 1775848 commit 47fe8ab

2 files changed

Lines changed: 2 additions & 24 deletions

File tree

src/Data/NodeResolver.php

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,10 @@ public function validate_term( \WP_Term $term ) {
8181
return null;
8282
}
8383

84-
// Check if an array has a key that starts with a string.
85-
$is_same_term = false;
86-
87-
$taxonomy = $term->taxonomy;
88-
89-
// Categories and Tags can use a shorthand in the query vars.
90-
if ( 'category' === $taxonomy ) {
91-
$taxonomy = 'cat';
92-
} elseif ( 'post_tag' === $taxonomy ) {
93-
$taxonomy = 'tag';
94-
}
95-
96-
foreach ( array_keys( $this->wp->query_vars ) as $key ) {
97-
if ( strpos( $key, $taxonomy ) === 0 ) {
98-
$is_same_term = true;
99-
break;
100-
}
101-
}
102-
103-
if ( ! $is_same_term ) {
84+
if ( isset( $this->wp->query_vars['taxonomy'] ) && $term->taxonomy !== $this->wp->query_vars['taxonomy'] ) {
10485
return null;
10586
}
10687

107-
10888
return $term;
10989
}
11090

@@ -359,11 +339,9 @@ public function parse_request( string $uri, $extra_query_vars = '' ) {
359339
*/
360340
global $wp_rewrite;
361341

362-
363342
$this->wp->query_vars = [];
364343
$post_type_query_vars = [];
365344

366-
367345
if ( is_array( $extra_query_vars ) ) {
368346
$this->wp->query_vars = &$extra_query_vars;
369347
} elseif ( ! empty( $extra_query_vars ) ) {
@@ -501,7 +479,6 @@ public function parse_request( string $uri, $extra_query_vars = '' ) {
501479
*/
502480
$this->wp->public_query_vars = apply_filters( 'query_vars', $this->wp->public_query_vars );
503481

504-
505482
foreach ( get_post_types( [ 'show_in_graphql' => true ], 'objects' ) as $post_type => $t ) {
506483
/** @var \WP_Post_Type $t */
507484
if ( $t->query_var ) {

src/Type/ObjectType/RootQuery.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ public static function register_term_object_fields() {
923923
$args['id'],
924924
[
925925
'nodeType' => 'TermNode',
926+
'taxonomy' => $tax_object->name,
926927
]
927928
);
928929
case 'global_id':

0 commit comments

Comments
 (0)