public function createSubRequest(
        string $relationship,
        ?ResourceInterface $resource = null,
        bool $keepFilters = false
    ): RequestInterface {
        $requestKey = $relationship . ($keepFilters ? '-filtered' : '-not-filtered');
        if (!\array_key_exists($requestKey, $this->subRequests)) {
            $includes = [];
            foreach ($this->includes as $include) {
                if (strpos($include, '.') !== false && strpos($include, $relationship . '.') === 0) {
                    $includes[] = explode('.', $include, 2)[1];
                }
            }

            $queryFields = [];
            foreach ($this->fields as $type => $fields) {
                $queryFields[$type] = implode(',', $fields);
            }

            $type = $resource ? $resource->type() : $this->type();
            $id = $resource ? $resource->id() : $this->id();
            $relationshipPart = '/' . $relationship;
            if (!$this->requestsInclude($relationship)) {
                $relationshipPart = '/relationships' . $relationshipPart;
            }

            $subRequest = new self(
                $this->method(),
                $this->uri()
                    ->withPath(($this->fileInPath ? '/' . $this->fileInPath : '') . ($this->apiPrefix ? '/' . $this->apiPrefix : '') . '/' . $type . '/' . $id . $relationshipPart)
                    ->withQuery(
                        http_build_query([
                            'fields' => $queryFields,
                            'filter' => $keepFilters ? $this->filter : [],
                            'include' => implode(',', $includes)
                        ])
                    ),
                null,
                $this->apiPrefix
            );
            $subRequest->headers = $this->headers;

            $this->subRequests[$requestKey] = $subRequest;
        }

        return $this->subRequests[$requestKey];
    }