jsonapi-converter icon indicating copy to clipboard operation
jsonapi-converter copied to clipboard

Allowing relationship links to get serialized for null relationship object

Open shipra-aeron opened this issue 4 years ago • 1 comments

The purpose of this PR is to allow to have all the relationships of a resource object to be always present inside relationships node and have links if they exists for a relationship.

As per the json api spec ->

A “relationship object” MUST contain at least one of the following:

  • links: a links object containing at least one of the following:
    • self: a link for the relationship itself (a “relationship link”). This link allows the client to directly manipulate the relationship. For example, removing an author through an article’s relationship URL would disconnect the person from the article without deleting the people resource itself. When fetched successfully, this link returns the linkage for the related resources as its primary data. (See Fetching Relationships.)
    • related: a related resource link
  • data: resource linkage
  • meta: a meta object that contains non-standard meta-information about the relationship.

Since above we have allowed all the relationships node to be always present, hence one should also provide a way to have atleast one to be always present out of the (data, meta and links)

The sole need for the above change is to make the client be aware of all the relationships associated with the resource objects.

shipra-aeron avatar Jan 07 '21 07:01 shipra-aeron

@shipra-aeron will take a look and comment/merge.

Thanks for the PR.

Edit: Currently bit ill, will probably take few days to do the above.

jasminb avatar Jan 07 '21 12:01 jasminb