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

Add a relationships() method to url builder #46

Open
ghunti opened this issue Jun 23, 2016 · 2 comments
Open

Add a relationships() method to url builder #46

ghunti opened this issue Jun 23, 2016 · 2 comments

Comments

@ghunti
Copy link

ghunti commented Jun 23, 2016

Hi

According to JSON API spec, you can update a relationship by using the "relationships" link ex post/1/relationships/comments.
Currently Devour only allows this through the resource link post/1 by adding the respective relationship object in the data sent to the server.
If we add a method similar in behavior to all and one to the url builder we could allow relationships links to work.
Ex

relationships () {
    this.builderStack.push({path: 'relationships'})
    return this
}

After this we could do something like jsonApi.one('post', 1).relationships().all('comments').post([{id: comment1Id}, {id: comment2Id}])

The "relationships" url could be configurable to allow more flexibility.
What do you think?

@Emerson
Copy link
Collaborator

Emerson commented Jul 1, 2016

This seems legit and I'd be happy to have it in our library.

@GregPeden
Copy link
Contributor

This was added by this PR
#99

I suggest this issue may be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants