Skip to content

feat: make the serialization of nil relationships configurable#403

Open
pwcsquared wants to merge 1 commit intobeam-community:mainfrom
pwcsquared:serialize-nil-rels-configurable
Open

feat: make the serialization of nil relationships configurable#403
pwcsquared wants to merge 1 commit intobeam-community:mainfrom
pwcsquared:serialize-nil-rels-configurable

Conversation

@pwcsquared
Copy link

Currently, singular relationships that are loaded on a resource but are nil in value are excluded from serialization by this library. While the JSON:API spec doesn't specifically say that all possible relationships must be serialized, it does mention that relationship resource linkages for empty to-one relationships should be represented as null.

This PR enables serializing these empty relationships as null through the configuration option :serialize_nil_relationships, which defaults to false to preserve existing functionality.

@pwcsquared pwcsquared requested a review from a team as a code owner March 10, 2026 20:57
@pwcsquared pwcsquared changed the title Make the serialization of nil relationships configurable feat: make the serialization of nil relationships configurable Mar 10, 2026
Enable serializing loaded nil associations serializable with the
:serialize_nil_relationships config option
@pwcsquared pwcsquared force-pushed the serialize-nil-rels-configurable branch from 003c4f2 to b76ec06 Compare March 10, 2026 22:08
Copy link
Member

@mattpolzin mattpolzin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me. I'll leave the PR open for a day or two to give time for other feedback.

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.

2 participants