NJsonApiCore icon indicating copy to clipboard operation
NJsonApiCore copied to clipboard

Fixed updating relationships, when no attributes are specified.

Open jasdefer opened this issue 9 years ago • 3 comments

A patch request modifying the relationship threw an error, because the attributes could not be initialized. An additional null check can solve this problem.

jasdefer avatar Nov 24 '16 14:11 jasdefer

I am very unfamiliar with the flow on GitHub and this is my first pull request ever. Don't hesitate and point out my mistakes.

jasdefer avatar Nov 24 '16 14:11 jasdefer

Hi there, thank you for your pull request. Please can you add Unit Tests for your change.

brainwipe avatar Nov 24 '16 15:11 brainwipe

Okay, I just looked at some tests and the WithResult(new ObjectResult(post)) method on the FilterContextBuilder seems to be creating the content for the requests. I am not sure how to create a Patch request like this:

PATCH /posts/1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
  "data": {
    "type": "post",
    "id": "1",
    "relationships": {
      "author": {
        "data": {"type": "people", "id": "2"}
      }
    }
  }
}

This request should be able to update the relationship of a post

jasdefer avatar Nov 24 '16 16:11 jasdefer