You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nothing weird so far. However, the API that my application talks to, sets the type / payload key as book. In order for the above to talk to the API correctly, my serializer adds the library- prefix on incoming payloads (via modelNameFromPayloadKey), and strips the prefix on outgoing requests (via payloadKeyFromModelName)
This all works great against the real API, but I've been having challenges getting that to work with factory guy.
When running a test that calls store.query('library-book', { page: 1 }) and debugging the incoming payload, it seems the type key (payload key) is set to 'library-book' when I need it to be 'book'. I would have thought that factory guy would call payloadKeyFromModelName from the serializer to figure out the necessary payload key to use, but my debugging shows that it doesn't seem to be called.
A quick search on this repo brings up this, which seems to indicate that payloadKeyFromModelName should be called when serializeMode is true - but I don't really know what that means or if I am able to set that easily.
I have a model, adapter and serializer for a
library-book
, which are are all jsonapiNothing weird so far. However, the API that my application talks to, sets the type / payload key as
book
. In order for the above to talk to the API correctly, my serializer adds thelibrary-
prefix on incoming payloads (viamodelNameFromPayloadKey
), and strips the prefix on outgoing requests (viapayloadKeyFromModelName
)This all works great against the real API, but I've been having challenges getting that to work with factory guy.
Consider the following example
When running a test that calls
store.query('library-book', { page: 1 })
and debugging the incoming payload, it seems thetype
key (payload key) is set to 'library-book' when I need it to be 'book'. I would have thought that factory guy would callpayloadKeyFromModelName
from the serializer to figure out the necessary payload key to use, but my debugging shows that it doesn't seem to be called.A quick search on this repo brings up this, which seems to indicate that
payloadKeyFromModelName
should be called when serializeMode is true - but I don't really know what that means or if I am able to set that easily.ember-data-factory-guy/addon/converter/jsonapi-fixture-converter.js
Lines 15 to 26 in 160aec8
Any help appreciated, thanks! (Even if the answer is "you can't do that", it'll save me digging into this further)
The text was updated successfully, but these errors were encountered: