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

Multi-word relationship names have wrong case during request #50

Open
CharlieIGG opened this issue Mar 24, 2019 · 1 comment
Open

Multi-word relationship names have wrong case during request #50

CharlieIGG opened this issue Mar 24, 2019 · 1 comment

Comments

@CharlieIGG
Copy link

CharlieIGG commented Mar 24, 2019

I have the following relationship:

class Thing extends resourceLibrary.Base {
        this.belongsTo('multiWord')
}

class MultiWord extends resourceLibrary.Base {
        this.hasMany('things')
}

MultiWord's relationship on my backend is obviously declared with snake case (belongs_to :multi_word) since I'm using Rails.

If I try to create or update a Thing with its nested MultiWord, JSON:API will expect the corresponding key in the relationships hash to be kebab-case, but ActiveResourceJS automatically converts it to snake_case when making the request:

Thing.build().assignMultiWord(multiWordInstance).save()
// yields ---> relationships: { multi_word: {...} }

Which results in a 400 response, with an error code "105: Param multi_word is not allowed".

Bypassing ActiveResourceJS for these requests and putting in relationships: { multi-word: {...} } makes everything work...

I've tried other formats for declaring the relationship, none of which seem to work:

class Thing extends resourceLibrary.Base {
        this.belongsTo('multi_word')
}
// doesn't work

class Thing extends resourceLibrary.Base {
        this.belongsTo('multi-word')
}
// can't even assign the association anymore
@CharlieIGG
Copy link
Author

Any help on this @nicklandgrebe ?

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

2 participants