$primary_data->
setHasNextPage($has_next_page);
// Calculate all the results and pass into a JSON:API Data object.
$count_query_cacheability =
new CacheableMetadata();
if ($resource_type->
includeCount()) { $count_query =
$this->
getCollectionCountQuery($resource_type,
$params,
$count_query_cacheability);
$total_results =
$this->
executeQueryInRenderContext( $count_query,
$count_query_cacheability );
$primary_data->
setTotalCount($total_results);
} $response =
$this->
respondWithCollection($primary_data,
$this->
getIncludes($request,
$primary_data),
$request,
$resource_type,
$params[OffsetPage::KEY_NAME
]);
$response->
addCacheableDependency($query_cacheability);
$response->
addCacheableDependency($count_query_cacheability);
$response->
addCacheableDependency((new CacheableMetadata()) ->
addCacheContexts([ 'url.query_args:filter',
'url.query_args:sort',
'url.query_args:page',
]));