Skip to content

Commit

Permalink
feat: allow including relationships by default (#96)
Browse files Browse the repository at this point in the history
* feat: default include

* Run Prettier

* chore: unnecessary import

---------

Co-authored-by: SychO9 <[email protected]>
  • Loading branch information
SychO9 and SychO9 authored Mar 29, 2024
1 parent a77e526 commit 7f108dd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Endpoint/Concerns/IncludesData.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@

trait IncludesData
{
protected ?array $defaultInclude = null;

public function defaultInclude(array $include): static
{
$this->defaultInclude = $include;

return $this;
}

private function getInclude(Context $context): array
{
if ($includeString = $context->request->getQueryParams()['include'] ?? null) {
if (
$includeString = $context->request->getQueryParams()['include'] ?? $this->defaultInclude
) {
$include = $this->parseInclude($includeString);

$this->validateInclude(
Expand Down

0 comments on commit 7f108dd

Please sign in to comment.