Countable relations, id encoding and non-Eloquent resources
Pre-release
Pre-release
·
217 commits
to main
since this release
Added
- #18 Added a
withCount
query parameter. For Eloquent resources, this allows a client to request the relationship count for the primary data's relationships. Refer to documentation for implementation details. - #55 Encoding and decoding of resource IDs is now supported. The
ID
field needs to implement theLaravelJsonApi\Contracts\Schema\IdEncoder
interface for this to work. - #41 Hash IDs are now supported by installing the
laravel-json-api/hashids
package and using theHashId
field instead of the standard EloquentID
field. Refer to documentation for details. - #30 Non-Eloquent resources are now supported via the
laravel-json-api/non-eloquent
package. Refer to documentation for implementation details. - There is now a
Core\Reponses\RelatedResponse
class for returning the result for a related resources endpoint. For example, the/api/v1/posts/1/comments
endpoint. Previously theDataResponse
class was used. While this class can still be used, the newRelatedResponse
class merges relationship meta into the top-levelmeta
member of the response document. For to-many relationships that are countable, this will mean the top-levelmeta
member will contain the count of the relationship. - The schema generator Artisan command now has a
--non-eloquent
option to generate a schema for a non-Eloquent resource.
Changed
- The
LaravelJsonApi::registerQuery()
,LaravelJsonApi::registerCollectionQuery()
andLaravelJsonApi::registerRequest()
methods must now be used to register custom HTTP request classes for specified resource types. Previously methods could be called on theRequestResolver
classes, but these have now been removed.
Fixed
- Relationship endpoints that return resource identifiers now correctly include page meta in the top-level meta member of the document, if the results are paginated. Previously the page meta was incorrectly omitted.