JSONAPI::Document::Builder::Relationships - Related Resource Document builder


version 2.4


Builds the related resource document for a given row.


The DBIx::Class::Row for relationship.

Note this is not the relationship row, rather it is its parent.


String name of the relationship.


Boolean; Default: false

If specified, will build the relationship with attributes instead of links.

Default behaviour is to build with links.

build : HashRef

Main caller method; Builds the related resource document.

Builds a HashRef containing strings that represent URLs for fetching the given relationship, as well as the relationship ID(s).

For referential purposes, self and related mean the following:


A link pointing to the relationship itself regardless of whether it is a one-to-one or has-many type of relationship. It contains the word "relationship" in the URL.

The specification defines this link as the link to the relationship itself in the context of the primary resource. This means that the resource(s) returned from this URL should be directly related to the primary resource, i.e. $dbic_row->$relationship.

Behaves the same as "self" except that its URL structure is different. I fail to see the difference.

build_document(DBIx::Class::Row $row, Str $relationship) : HashRef

Builds a HashRef of the relationship(s) with attributes.

build_single_document(DBIx::Class::Row $related_row, Str $relationship) : HashRef

Builds a HashRef representing a single relationship row.