neomerx / json-api

Framework agnostic JSON API (jsonapi.org) implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested relationships and links

designermonkey opened this issue · comments

I can use the provided function to get document level links for a single level of nested relationship:

{
    "links": {
        "related": "\/types\/0001\/sub-types"
    }
}

Do you know of a simple way to have links generated for multiple levels of nesting?

{
    "links": {
        "related": "\/types\/0001\/sub-types\/0002\/properties"
    }
}

Also, this applies to the relationship links generated by a schema; I can do simple single levels, but don't know how to do the same described multi levels.

Any pointers you may have?

try adding to LINKS subsection of your schema Schema a link

self::LINKS => [
    LinkInterface::RELATED => new Link('www.any-url-here.foo'),
    'custom-link'          => new Link('www.custom-links-are-supported-too'),
]

if you add RELATED it will override default one.

UPD: added link to a sample

I've updated the wiki with an answer to this question and have a feeling it's answered. If you have any further questions please don't hesitate to ask.