@iamsebastian wrote:
Hello,
I'm actually fresh to a new company and would like to "professionalize" their product from un-maintainable some-very-large-few-single-files-PHP project, over, to a maintainable, JSONAPI based resolution build upon Ember on client side, and Node/Express on server side.
My experience is based at least on two years of full-time node.js experience and about a year of angular before the dive-into node.js-backends. Actually I'm struggling around, with JSONAPI-compatible relationships.
I've tried to show you in a lighten version, what I'm done until now here: https://ember-twiddle.com/7f5c3017eba2dbeacdbf (just look at the sources -- not at the resulting html on the right side)
I'm trying to establish a connection between two models:
bankanduser. While the user has abelongsTobank-id(/bankId), thebankdoes not has a inverse relationship.The JSON, my API responds with actually, is there: https://gist.github.com/iamsebastian/9afad6bc56fcede54e6b
As you can see, the
userhas abank-idwhich I actuallydeserializeto {bank-id -> bank}, so ember-data get's knowledge about, which models have to be connected here.Now the question:
All is working well, if I send out thebank-idasuser's attribute. But ember-data does not connect the two models, if I do not send out thebank-idproperty. But as far as I could read from the JSONAPI specification and the ember docs, thebelongsTo-relationship betweenbank&usershould be already established in because of this part of the response:The data is correctly parsed by ember and the adapters, like you will see here:
Feel free to ask me anything about that, if it would help to let you understand my question.
Another awkward question:
I also could not get ember-data to "auto-request" missing relationships if I removed the relationships from the API response and just transmitted thebank-idat the user, to let ember know, whichbankshould get requested viahttps://host/api/bank/$id. There was a fulFilled promise attached to each user, but no visible try in the networks-tab of the inspector, where ember was requesting the missing record data of the relatedbank.
Posts: 1
Participants: 1
