protected function buildRelationships()
    {
        if (isset($this->relationships)) {
            return $this->relationships;
        }

        $paths = Util::parseRelationshipPaths($this->includes);

        $relationships = [];

        foreach ($paths as $name => $nested) {
            $relationship = $this->serializer->getRelationship($this->data, $name);

            if ($relationship) {
                $relationshipData = $relationship->getData();
                if ($relationshipData instanceof ElementInterface) {
                    $relationshipData->with($nested)->fields($this->fields);
                }

                $relationships[$name] = $relationship;
            }
        }

        return $this->relationships = $relationships;
    }