ember-cli-mirage icon indicating copy to clipboard operation
ember-cli-mirage copied to clipboard

Configure route to add relationships but not includes to the response payload

Open andrew-paterson opened this issue 4 years ago • 1 comments

For models that have a belongsTo relationship, the API which I'm mocking:

  • will sometimes ignore related data entirely (Neither relationships nor includes are part of the response payload),
  • will sometimes include both relationships and includes in the response payload.
  • will sometimes include the relationships object, but will not sideload the data, so includes is not a part of the response payload,

Case 1 is solved by setting alwaysIncludeLinkageData to false.

Case 2 is solved by using the includes query param.

Does Mirage have a built-in way to configure an individual route in config.js to have relationships in the payload, but not the includes array?

andrew-paterson avatar May 23 '20 06:05 andrew-paterson

Hi @andrew-paterson , you could try to overwrite the serializer's include property and/or serialize method.

albuquerquecesar avatar Jun 04 '20 19:06 albuquerquecesar