Closed danshapir closed 9 years ago
I've changed the extractRelationships into privateExtractRelationships since it doesn't fit the signature of the actual extractRelationships and it seems no one is calling it but the serializer itself. Seems to work for me, but that's the only change I can't vet.
@danshapir You mentioned that you've fixed the code to support errors. Do you have any more details? I'm currently using this in a project and errors returned from our API are working as expected.
I like the support for the isInvalid
API. I'm just trying to understand what was broken before understanding the new code.
@CrshOverride
Sure,
First regarding the where you'd run into this issue?: If you want to make your response smaller you can return the ids of the related properties (either o-m or o-o), if you do that the "record" is not an actual record, it's just the id, so ember will either load it async when required if it's not already loaded or just understand the connections as is (this is how all the Node.JS/Ruby API work to get a lower footprint json). Sample:
{
user: {
userName: 'Dan',
age: 150,
comments: [1,4,12,45],
ownerId: 3
}
This means that ember knows that comments with the ids 1,4,12,45 are related to that user, it will load them async when required, same for ownerId which is a belongsTo connection.
I'm using the latest, out of the box WebAPI and it's response structure, with the way the code was working now it didn't work. But again, it's not the WebAPI that is different between the two of us, I'm just using the latest Ember-Data, they changed the way the consume and handle errors: http://emberjs.com/blog/2015/06/18/ember-data-1-13-released.html#toc_using-json-api-error-object-format
Let me know if you need any more data :smile:
@danshapir It also looks like your code's Unit Tests fail. Those issues need to be taken care of as well.
Let me know if you have any other questions. I definitely appreciate the feedback!
Fixed
@crshoverride
I've fixed the code so that errors returned from the API will work (and upgraded the code to work with the new ember-data isInvalid API)
I've also removed the model web-api from the app folder which killed the Ember Inspector