Add resource identifier metadata marshaling - #81
Conversation
a835709 to
36658a1
Compare
|
/code blockers |
|
View all feedbacks in Devflow UI.
Checking merge blockers for #81...
Detected 1 merge blocker(s) to address: 🔴 Blocking |
bb78033 to
65ab036
Compare
|
/remove |
|
View all feedbacks in Devflow UI.
|
|
/code blockers |
|
View all feedbacks in Devflow UI.
Checking merge blockers for #81...
No merge blockers detected. |
|
/merge |
|
View all feedbacks in Devflow UI.
PR already in the queue with status in_progress |
|
/remove |
|
View all feedbacks in Devflow UI.
|
|
/merge -m squash |
|
View all feedbacks in Devflow UI.
The expected merge time in
The merge request has been interrupted because the build 0 took longer than expected. The current limit for the base branch 'main' is 120 minutes. |
Related Issue
#80
Description
This change adds the optional
MarshalResourceIdentifierMetainterface. Related resources can implement it to add metadata to each resource identifier object.For example:
The relationship data now contains distinct metadata on each resource identifier:
{ "data": { "type": "layers", "id": "layer-a", "relationships": { "nodes": { "data": [ {"type": "nodes", "id": "node-a", "meta": {"index": 0}}, {"type": "nodes", "id": "node-b", "meta": {"index": 1}} ] } } } }Previously,
jsonapi:"meta"could only add metadata to the relationship object itself. Adding per-identifier metadata required modifying the encoded JSON after marshaling.The existing relationship-object metadata behavior is unchanged. Identifier metadata uses the existing metadata validation, omits nil values, and preserves an empty metadata object.
Additional context
Tests cover to-one and to-many relationships, distinct metadata, nil and typed nil values, empty objects, invalid values, and both metadata locations together.
Local checks passed:
go test ./...go test -race ./...go vet ./...