I have little experience in Ember. Im not in control of the server and so path to certain resources are different as JSONAPI specs but for the most part it matches it.
I have the following structure for my models:
/models
|-- myModel
|-- generalModel (polymorphic model)
|--/generalModel
|--modelTypeA
|--modelTypeB
where myModel hasMany generalModel being declared as polymorphic. Taking into account that it is a polymorphic model, when I use the method findRecord('my-model', id, {include: 'general-models'})
the responses tend to be like:
response: {
data: {
attributes: {...},
id: XXX,
relationships: {
general-models: {
data: [
{ type: 'general-model/model-type-a', id: YYY }
]
}
}
}
}
How can I modify the responses in mirage, so instead of { type: 'general-model/model-type-a', id: YYY }
I would return { type: 'general-model-a', id: YYY }
?
This is a simplify scenario, so the focus is in what hook mirage provides to modify the type in relationship when using subfolders for models.
I have tried using serializers for general-model but it seems that they dont get call at all. Mirage does not support subfolder structure in models, so I cannot defined a serializers for model-type-a. It crashes saying Assertion Failed: Subdirectories under BLABLA are not supported
.
I have seen https://github.com/samselikoff/ember-cli-mirage/issues/663 and https://github.com/samselikoff/ember-cli-mirage/issues/540 and I dont know workaround.
Any ideas?
Aucun commentaire:
Enregistrer un commentaire