-
Notifications
You must be signed in to change notification settings - Fork 14
Ensure relationship keys are de-camelized in write payload #40
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
Conversation
}); | ||
|
||
// todo test on the way back - id set, attrs updated, isPersisted | ||
// todo remove #destroy? and just save when markwithpersisted? combo? for ombined payload | ||
// todo test unique includes/circular relationshio | ||
it('sends the correct payload', function(done) { | ||
instance.save({ with: { books: 'genre' } }).then((response) => { | ||
instance.save({ with: { books: 'genre', specialBooks: true } }).then((response) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super minor, but could we make this specialBooks: {}
? It better models what we actually expect (and will enforce in TypeScript soon), the true
just happens to work here and these tests can be useful as documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh yes - was honestly just a guess on my part 😄 updated!
@jplhomer one minor comment but this is fantastic, thank you 👏 ! I find it unbelievable I have not come across this before, perhaps one of the minor bumps along the way introduced this. At least now we have a spec in the right place. Very much appreciated! ❤️ (I know @wadetandy has had better luck importing lodash functions in TypeScript for things like |
Released in |
Pulls in the test and re-implements functionality for jsonapi-suite#40. Also removes a bunch of superfluous string methods. We had snakeCase coming from lodash and an internal camelize function. Since we're using the inflected library for jsonapiType manipulation, we can rely on its underscore and camelize functions.
Implement #40 Pulls in the test and re-implements functionality for #40. Also removes a bunch of superfluous string methods. We had snakeCase coming from lodash and an internal camelize function. Since we're using the inflected library for jsonapiType manipulation, we can rely on its underscore and camelize functions.
We're seeing an issue where a multi-word relationship key (in Rails) is receiving a write payload with a camelized key. The write fails in this case:
This PR adds a test for this behavior, and introduces the
decamelize
string helper.Definitely open to more elegant ways to do this without decamelizing a string!