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.
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. https://github.com/adopted-ember-addons/ember-data-factory-guy/blob/160aec825ef73f085b40eca9868f988f05389d69/addon/converter/jsonapi-fixture-converter.js#L15-L26Any help appreciated, thanks! (Even if the answer is "you can't do that", it'll save me digging into this further)