Skip to content

Commit

Permalink
Merge branch '8.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi committed Dec 21, 2024
2 parents 69ce03e + 065c8e7 commit 8933300
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
17 changes: 0 additions & 17 deletions config/apiato.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,6 @@
// TODO: BC: remove this after removing its usage in ResponseTrait in Core
'filter' => 'fieldset',
],

/*
|--------------------------------------------------------------------------
| Sparse Fieldsets
|--------------------------------------------------------------------------
|
| Sparse Fieldsets are a feature of the JSON API spec that allows clients to request only a subset of the
| attributes for a specific resource type. This can be useful for improving performance by reducing the amount
| of data that needs to be transferred over the network.
|
| @see https://jsonapi.org/format/#fetching-sparse-fieldsets
|
*/
'sparse_fieldsets' => [
// The name of key in the request to where we should look for the fields to return.
'request_key' => 'fields',
],
],

'seeders' => [
Expand Down
7 changes: 4 additions & 3 deletions tests/Unit/Services/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ public function testPaginatedResourceMetaDataAndInclude($include): void
}

#[DataProvider('fieldsetDataProvider')]
public function testCanFilterResponse($fieldset, $expected, $missing): void
public function testCanFilterResponse($fields, $expected, $missing): void
{
request()->merge(['include' => 'books,children.books', self::FIELDSET_KEY => $fieldset]);
request()->merge(['include' => 'books,children.books', self::FIELDSET_KEY => $fields]);
$response = Response::create($this->user);
$response->transformWith(UserTransformer::class);

Expand Down Expand Up @@ -344,7 +344,8 @@ protected function setUp(): void
{
parent::setUp();

config()->set('apiato.requests.sparse_fieldsets.request_key', self::FIELDSET_KEY);
config()->set('fractal.auto_fieldsets.enabled', true);
config()->set('fractal.auto_fieldsets.request_key', self::FIELDSET_KEY);

$this->user = UserFactory::new()
->for(UserFactory::new()->has(BookFactory::new()), 'parent')
Expand Down

0 comments on commit 8933300

Please sign in to comment.