Skip to content

Conversation

ArneZsng
Copy link
Contributor

@ArneZsng ArneZsng commented Jul 5, 2018

All Submissions:

  • I've checked to ensure there aren't other open Pull Requests for the same update/change.
  • I've submitted a ticket for my issue if one did not already exist.
  • My submission passes all tests. (Please run the full test suite locally to cut down on noise from travis failures.)
  • I've used Github auto-closing keywords in the commit message or the description.
  • I've added/updated tests for this change.

Bug fixes and Changes to Core Features:

  • I've included an explanation of what the changes do and why I'd like you to include them.
  • I've provided test(s) that fails without the change.

When adding a relationship that already exists or multiple relationships of which at least one already exists, the response is a 400 Bad Request and the relationships are not updated/created. In our specific case we expected the API to behave differently and if I am not misinterpreting http://jsonapi.org, the expected response is actually a different one.

To quote http://jsonapi.org/ (http://jsonapi.org/format/#crud-updating-to-many-relationships):

If all of the specified resources can be added to, or are already present in, the relationship then the server MUST return a successful response.
Note: This approach ensures that a request is successful if the server’s state matches the requested state, and helps avoid pointless race conditions caused by multiple clients making the same changes to a relationship.

Fixes #1168

Reviewer Checklist:

  • Maintains compliance with JSON:API
  • Adequate test coverage exists to prevent regressions

@lgebhardt lgebhardt merged commit 78a2edd into cerebris:master Jul 6, 2018
@lgebhardt
Copy link
Member

@ArneZsng Thanks!

@ArneZsng ArneZsng deleted the hotfix-master/allow-to-post-exisiting-relationships branch July 6, 2018 13:49
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.

Allow to post existing relationships
2 participants