diff --git a/src/TermObject.php b/src/TermObject.php index bd35283..ef25c84 100644 --- a/src/TermObject.php +++ b/src/TermObject.php @@ -172,7 +172,7 @@ function ($term_id, $args) { continue; } - $terms[] = $translation; + $terms[] = new \WPGraphQL\Model\Term($translation); } return $terms; diff --git a/tests/wpunit/TermObjectQueryTest.php b/tests/wpunit/TermObjectQueryTest.php index da5e502..e605bf4 100644 --- a/tests/wpunit/TermObjectQueryTest.php +++ b/tests/wpunit/TermObjectQueryTest.php @@ -160,6 +160,31 @@ public function testCanFetchTranslatedTermVersions() $this->assertEquals($expected, $data['data']['tags']['nodes']); } + public function testCanFetchTranslatedTermVersionsWithIds() + { + pll_save_term_translations([ + 'en' => $this->en_term_id, + 'fi' => $this->fi_term_id, + ]); + + $query = " + query Tags { + tags { + nodes { + name + translations { + id + } + } + } + } + "; + + $data = do_graphql_request($query); + $this->assertArrayNotHasKey('errors', $data, print_r($data, true)); + + } + public function testCanFetchSpecificTranslatedVersion() { pll_save_term_translations([