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

JSON API is agnostic about filter strategies, and so should Spine be #129

Closed davidstosik closed 7 years ago

davidstosik commented 7 years ago

Hello,

According to the specification,

JSON API is agnostic about the strategies supported by a server. The filter query parameter can be used as the basis for any number of filtering strategies.

Recently, it looks like Query lost public methods such as filterOn and addPredicateWithKey (no explicit access level, thus internal) that allowed someone to filter a query on something that is not an attribute. For example, our JSON API implementation defines a filter named my_stream, and the results will be filtered to contain items that pertain to the user's stream, but my_stream is actually not an attribute on any of our resources.

Is there another way that I'm missing, to build a query with a filter on a keyword that is not an attribute, or did Spine indeed lose that feature? If so, according to the specification, wouldn't it make sense to restore something?

Also see #83 and #84.

koraykoska commented 7 years ago

I'll try to fix this and open a pull request. There should not be a restriction about the filters...

wvteijlingen commented 7 years ago

Sorry about the delay on this. I've been quite busy and this got lost in my inbox.

You're totally right, this should be fixed. I think this can be fixed quite swiftly by making addPredicateWithKey and addPredicateWithField public.

Then you can use the whereAttubute methods for most basic uses cases, and add custom predicates for more complex filtering.

davidstosik commented 7 years ago

Thanks!