Skip to content

feat: Add JSON:API sparse fieldset relationship support#410

Open
mattpolzin wants to merge 1 commit intomainfrom
sparse-fieldset-rels
Open

feat: Add JSON:API sparse fieldset relationship support#410
mattpolzin wants to merge 1 commit intomainfrom
sparse-fieldset-rels

Conversation

@mattpolzin
Copy link
Copy Markdown
Member

@mattpolzin mattpolzin commented Apr 6, 2026

Fixes #408.

The JSON:API specification allows for sparse fieldsets to limit both attribute and relationship serialization. Until now, this library only appliled sparse fieldset handling to attributes.

This adds relationship support.

Adding this support is a bit fiddly given this library already treats "fields" as a synonym for "attributes" in more than a couple of places. In order to not rip the carpet up, I chose to make this a mostly non-breaking change. I say mostly because there is still one important catch: If an existing API assumes the non-standard behavior of only filtering attributes by the sparse fieldset query parameter, then clients may request a fieldset not including relationship values that they expect to have serialized and this PR will break those API requests (which must now specify the relationship names in the sparse fieldset query parameter going forward).

Still, I consider this a bug fix given the specification is very clear about how sparse fieldsets work. Hopefully no one sees regressions in their own APIs due to this behavioral change.

@mattpolzin mattpolzin requested a review from a team as a code owner April 6, 2026 15:56
@mattpolzin mattpolzin changed the title Add JSON:API sparse fieldset relationship support feat: Add JSON:API sparse fieldset relationship support Apr 8, 2026
@mattpolzin mattpolzin force-pushed the sparse-fieldset-rels branch 2 times, most recently from 653ffc3 to 1f36812 Compare April 8, 2026 22:15
The JSON:API specification allows for sparse fieldsets to limit both
attribute and relationship serialization. Until now, this library only
appliled sparse fieldset handling to attributes.

This adds relationship support.
@mattpolzin mattpolzin force-pushed the sparse-fieldset-rels branch from 1f36812 to c87faa1 Compare April 8, 2026 22:15
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

Successfully merging this pull request may close these issues.

sparse fieldsets do not support relationship fields

1 participant