-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Got a trouble with 500 error using sparse fields #26
Comments
Hey! Can you post a slightly longer stack trace please? |
The full long stack trace is here, sir
|
Hello, The error came from this line https://github.com/laravel-json-api/core/blob/ba1c5e3104bd0b30197e112ae8fdcb4fa15231ca/src/Core/Query/FieldSets.php#L74: Here $fields is a string, hence it's failing. As a quick workaround I use : return new self(...collect($value)->map(function ($fields, string $type) {
if (is_string($fields)) {
$fields = explode(',', $fields);
}
return new FieldSet($type, ...$fields);
})->values()); But something tells me that exploding $fields shouldn't be done here and maybe not in any case. |
Fixed in 18471a3 |
Can't use sparse fields option of specificaction (https://jsonapi.org/format/#fetching-sparse-fieldsets) like this:
GET api/v1/posts?include=user&fields[posts]=title
, I am getting 500 error end an exception:"message": "Argument 1 passed to LaravelJsonApi\\Core\\Query\\FieldSets::LaravelJsonApi\\Core\\Query\\{closure}() must be of the type array, string given", "exception": "TypeError", "file": "/var/www/html/vendor/laravel-json-api/core/src/Core/Query/FieldSets.php", "line": 74,
The text was updated successfully, but these errors were encountered: