wvteijlingen / Spine

A Swift library for working with JSON:API APIs. It supports mapping to custom model classes, fetching, advanced querying, linking and persisting.
MIT License
264 stars 109 forks source link

Supporting sorting based on field outside `fields` #155

Open michalbanan opened 7 years ago

michalbanan commented 7 years ago

Is there any way i can add sorting order based on key which is not a field in my referrence model? On my backend serwer i have ability to fetch data sorted by distance adding query parameter distance. But model i can fetch using this request does not contain field called like that so i end up with compile error: Cannot restrict to field distance of resource entity. No such field has been configured. So is there any other possibility i can build up request like this?

wvteijlingen commented 7 years ago

Currently this is not possible. This problem existed for filtering as well, which we fixed. We should do the same thing for sorting. From the top of my head the field check should be changed in Query, and then the Router should be updated to allow custom fields as well.