You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@JaviLerma@luizmagao
The current implementation doesn't work as expected due to several factors related to naming conventions and configuration:
Relationship and Table Naming:
By default, the query builder expects plural names for relations and table names. For example:
'author' should be 'authors'
'postComment' should be 'postComments'
Using Singular Names:
If you prefer to use singular naming for relationships, you need to publish the query-builder config file: php artisan vendor:publish --provider="Spatie\QueryBuilder\QueryBuilderServiceProvider" --tag="query-builder-config"
Then, set convert_relation_names_to_snake_case_plural to false in the config file.
Relation ID Fields:
Ensure you add the relation id to the fields param
Query Syntax:
You can query related fields using either of these syntaxes:
Greetings from Argentina!
The Official docs says:
GET /posts?include=author&fields[author]=id,name
Return all post but only id and name of the author, but it doesn't work. It fetches all the authors fields.
Relationships
User model:
Post model:
I am doing something wrong or its a bug?
Thanks
The text was updated successfully, but these errors were encountered: