Skip to content

Clearing a resource relationship #223

@bensullivan

Description

@bensullivan

Hi

We have a requirement to be able to clear (make null) an existing relationship on a resource. As far as I'm aware the JSON:API spec supports this (where prior to this example PATCH request, the author relationship was "data": { "type": "people", "id": "1" }):

PATCH /articles/1 HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "type": "articles",
    "id": "1",
    "relationships": {
      "author": {
        "data": null
      }
    }
  }
}

When I come to deserialise a request like this I am getting a InvalidJsonApiResourceException: Resource must contain at least one of 'data', 'error' or 'meta' nodes.

Assuming my interpretation of the JSON:API spec for this scenario isn't wrong, is there a way to clear resource relationships with jsonapi-converter?

Thanks for your help!

Ben

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions