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
Hi,
Nice work on your gem the files and classes structures really ease the read of the code.
I was discovering the specification of JSON:API while testing your gem and I've seen some behaviors that doesn't seem to respect it.
Can I ask you why all the returned results are ResultSet and not some times resources when querying only one specific resource?
Can you give me some details on the usefulness of the last_result_set attribute?
Thanks by advance for your answer.
The text was updated successfully, but these errors were encountered:
I always have the request return a JsonApiClient::ResultSet so that I can be confident in the return type (and that I have access to the meta data of the response as well). The fact that it always returns an array-like thing is a remnant from the initial specifications where every endpoint was supposed to return an array (so you can always iterate over all the results like you can in jQuery).
The switch back to singular/multiple resource objects returned was a pretty late design change in the spec and I had already implemented and was using a pre-release version (I still maintain a 0.x branch). I decided that the consumer of the client shouldn't have to interrogate to see if you could call each or just use the resulting object and just always know that it's an array-like thing. As a consumer, if you know you get back 0 or 1 things, then you can call .first on the result set.
The last_result_set attribute is there if you are doing actions on a resource instance (like update) and you want access to the metadata. .save on resource instance behaves similarly to ActiveRecord (returns true/false) and sets errors if it failed. If you don't have access to the last_result_set, then we've lost metadata from that request.
Hi,
Nice work on your gem the files and classes structures really ease the read of the code.
I was discovering the specification of JSON:API while testing your gem and I've seen some behaviors that doesn't seem to respect it.
Thanks by advance for your answer.
The text was updated successfully, but these errors were encountered: