cloudcreativity / laravel-json-api

JSON API (jsonapi.org) package for Laravel applications.
http://laravel-json-api.readthedocs.io/en/latest/
Apache License 2.0
778 stars 109 forks source link

How to stop this library from making asterix queries? #633

Closed ProteanCode closed 2 years ago

ProteanCode commented 2 years ago

Hello

I am using a V2 of that library, but I also noticed that in SQL logs it does a whole query search (SELECT * FROM foo) for uknown to me reason

The slice of execution stack trace:

`#8 /var/www/html/vendor/laravel-json-api/core/src/Core/Resources/ResourceCollection.php(111): Illuminate\Support\LazyCollection->Illuminate\Support\{closure}()

9 /var/www/html/vendor/laravel-json-api/core/src/Core/Resources/Container.php(107): LaravelJsonApi\Core\Resources\ResourceCollection->getIterator()

10 /var/www/html/vendor/laravel-json-api/neomerx-json-api/src/Parser/Parser.php(152): LaravelJsonApi\Core\Resources\Container->cursor(Object(LaravelJsonApi\Core\Resources\ResourceCollection))

11 /var/www/html/vendor/laravel-json-api/neomerx-json-api/src/Parser/Parser.php(131): Neomerx\JsonApi\Parser\Parser->parseAsResourcesOrIdentifiers(Object(Neomerx\JsonApi\Contracts\Schema\PositionInterface@anonymous), Object(Generator))

12 /var/www/html/vendor/laravel-json-api/neomerx-json-api/src/Encoder/Encoder.php(191): Neomerx\JsonApi\Parser\Parser->parse(Object(Generator), Array)

13 /var/www/html/vendor/laravel-json-api/neomerx-json-api/src/Encoder/Encoder.php(106): Neomerx\JsonApi\Encoder\Encoder->encodeDataToArray(Object(Generator))

14 /var/www/html/vendor/laravel-json-api/encoder-neomerx/src/CompoundDocument.php(61): Neomerx\JsonApi\Encoder\Encoder->encodeData(Object(Generator))

15 /var/www/html/vendor/laravel-json-api/encoder-neomerx/src/Document.php(191): LaravelJsonApi\Encoder\Neomerx\CompoundDocument->encode()

16 /var/www/html/vendor/laravel-json-api/core/src/Core/Responses/Internal/ResourceCollectionResponse.php(88): LaravelJsonApi\Encoder\Neomerx\Document->toJson(0)

17 /var/www/html/vendor/laravel-json-api/core/src/Core/Responses/DataResponse.php(120): LaravelJsonApi\Core\Responses\Internal\ResourceCollectionResponse->toResponse(Object(Illuminate\Http\Request))

18 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(802): LaravelJsonApi\Core\Responses\DataResponse->toResponse(Object(Illuminate\Http\Request))`

I am not sure that makes it run an asterix query

lindyhopchris commented 2 years ago

Hi! If you're on v2 as you say, then I believe you're actually on the laravel-json-api/laravel package - so you've opened this issue in the wrong repo.

An issue about this already exists in the right repo - see this https://github.com/laravel-json-api/laravel/issues/146