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

store.push can't handle top-level JSON API types being plural #3541

Closed
kagemusha opened this issue Jul 13, 2015 · 5 comments
Closed

store.push can't handle top-level JSON API types being plural #3541

kagemusha opened this issue Jul 13, 2015 · 5 comments

Comments

@kagemusha
Copy link
Contributor

Looking the jsonapi format doc seems top-level types should be plural, yet store.push fails when you pass plurals.

Failure is at the modelFor call in _pushInternalModel fn in store

As plurals work fine for store.findRecords, shouldn't they work here too?

@bmac
Copy link
Member

bmac commented Jul 13, 2015

@kagemusha Try using store.pushPayload instead of push. push currently expects the top level keys to be singular and the relationship and attribute names to be match the names defined on your record.

The JSONAPISerializer automatically singularizes the type and undasherizes the attribute and relationship names when it runs on the payload returned by store.findRecord.

store.pushPayload runs the payload through the serializer before passing it to store.push.

@bmac
Copy link
Member

bmac commented Jul 13, 2015

@wecc Maybe we should assert that ED can lookup the type in store.push with a message instructing people to use store.pushPayload instead if that fails.

@kagemusha
Copy link
Contributor Author

@bmac thanks, that works. Thought i read somewhere that pushPayload gonna be deprecated at some point and everything will go thru push in future. In that the case?

@wecc
Copy link
Contributor

wecc commented Jul 13, 2015

@bmac agree, I think we should assert that type is found in _pushInternalModel

Edit: #3542

@kagemusha
Copy link
Contributor Author

@bmac @wecc Won't ember data types always be singular? Why not singularize here instead (or in addition) to the assert?

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

3 participants