Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
olokobayusuf opened this issue Aug 6, 2018 · 1 comment
Closed

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

olokobayusuf opened this issue Aug 6, 2018 · 1 comment

Comments

@olokobayusuf
Copy link

olokobayusuf commented Aug 6, 2018

  • Suppose I have a base schema A, and another schema B : A
  • Suppose we have two fields on A, someField and anotherField
  • When performing a GET on B with sparse field sets, the field sets are ignored (likely because they are not defined directly on B):
api.somewhere.com/B?fields[B]=someField,anotherField
  • Expected behaviour is that field sets are inherited, since A's fields are B's fields
@ethanresnick
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants