ethanresnick / json-api

Turn your node app into a JSON API server (http://jsonapi.org/)
GNU Lesser General Public License v3.0
268 stars 41 forks source link

Sparse field sets don't work with inherited types #177

Closed olokobayusuf closed 6 years ago

olokobayusuf commented 6 years ago
ethanresnick commented 6 years ago

Under the JSON:API spec, the value in the square brackets for ?fields[TYPE] must match the value serialized in the resource object's type key for the sparse fieldset list to take effect.

Subtypes are serialized with their parent type in the type key (an intentional decision discussed #149), so the library's current behavior is actually correct per the JSON:API spec.

If you want to filter the subtype's fields, then, you actually have to put the supertype in the query string:

api.somewhere.com/B?fields[A]=someField,anotherField