Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use DELETE method for 'to-many' relationships #63

Open
saernz opened this issue Oct 19, 2018 · 0 comments
Open

Can't use DELETE method for 'to-many' relationships #63

saernz opened this issue Oct 19, 2018 · 0 comments

Comments

@saernz
Copy link

saernz commented Oct 19, 2018

Hey guys great job on the module. I think I found an issue where the library isn't exactly following JSONAPI spec, though possibly I'm interpreting the spec wrong too.

I tried to do a call to an api endpoint like so { method: destroy, path: '/post/:id/relationships/comments' } with the following payload:

{
    data: [
        { type: "comments", id: "1" },
        { type: "comments", id: "2" }
   ]
}

I expected to see that these relationship records would be deleted though I ended up getting an error from my server as the body of the JSONAPI request was missing.
This is due to http method not adding the body for a DELETE request here in the destroy function, which would normally make sense apart from when you're destroying resources that are part of a 'to-many' relationship.

In the JSONAPI spec in the 'updating to-many relationships' section it says:

A server MUST respond to PATCH, POST, and DELETE requests to a URL from a to-many relationship link as described below. For all request types, the body MUST contain a data member whose value is an empty array or an array of resource identifier objects.

Obviously because the destroy method does not include the body this will not work in redux-bees. I have tried running the query in a curl request to my laravel JSONAPI server with no problem so it seems at least my PHP JSONAPI library has also interpreted the spec the same as what I have.

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

No branches or pull requests

1 participant