Skip to content

Commit

Permalink
Ensure terms translations can be fetched with IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
esamattis committed Feb 11, 2020
1 parent 304a278 commit 3abf304
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/TermObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function ($term_id, $args) {
continue;
}

$terms[] = $translation;
$terms[] = new \WPGraphQL\Model\Term($translation);
}

return $terms;
Expand Down
25 changes: 25 additions & 0 deletions tests/wpunit/TermObjectQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down

0 comments on commit 3abf304

Please sign in to comment.