Skip to content

Commit 7df6633

Browse files
committed
[Feature] Improve/fix handling of links on relationship documents
See #111 See #105
1 parent 32fe61e commit 7df6633

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ All notable changes to this project will be documented in this file. This projec
1313
- [#127](https://github.com/laravel-json-api/laravel/issues/127) The `JsonApiResource` class now has a
1414
protected `serializeRelation` method that can be used to override the default serialization of relationships if
1515
needed.
16+
- [#111](https://github.com/laravel-json-api/laravel/issues/111) Relationship documents returned by relationship `self`
17+
routes will now include any non-standard links set on the resource relationship in the top-level `links` member.
1618

1719
### Fixed
1820

1921
- [#130](https://github.com/laravel-json-api/laravel/issues/130) The `JsonApiResource` now correctly handles conditional
2022
fields when iterating over relationships to find a specific relation.
23+
- [#105](https://github.com/laravel-json-api/laravel/issues/105) The JSON:API document returned by a relationship `self`
24+
route now handles a relationship not existing if it is hidden. Previously an exception was thrown when attempting to
25+
merge relationship links into the document.
26+
- [#111](https://github.com/laravel-json-api/laravel/issues/111) Relationship documents now handle a relationship that
27+
does not have one or both of the `self` and `related` relationship links.
2128

2229
## [1.0.1] - 2021-12-08
2330

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"ext-json": "*",
2828
"laravel-json-api/core": "^1.1",
2929
"laravel-json-api/eloquent": "^1.0.1",
30-
"laravel-json-api/encoder-neomerx": "^1.0.0",
30+
"laravel-json-api/encoder-neomerx": "^1.1",
3131
"laravel-json-api/exceptions": "^1.0.0",
3232
"laravel-json-api/spec": "^1.0.0",
3333
"laravel-json-api/validation": "^1.0.0",

tests/dummy/tests/Api/V1/Posts/ReadTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public function test(): void
3737
->withoutExceptionHandling()
3838
->jsonApi()
3939
->expects('posts')
40-
->get(url('/api/v1/posts', $expected['id']));
40+
->get($self = url('/api/v1/posts', $expected['id']));
4141

42-
$response->assertFetchedOneExact($expected);
42+
$response->assertFetchedOneExact($expected)->assertLinks(compact('self'));
4343
}
4444

4545
public function testIncludeAuthorAndTags(): void

0 commit comments

Comments
 (0)