loopback-component-jsonapi icon indicating copy to clipboard operation
loopback-component-jsonapi copied to clipboard

[BUGFIX] include may not have a .relation and just be a { [modelName]: true } sometimes

Open abhilashmurthy opened this issue 4 years ago • 1 comments

Used to fail when my model has a default scope in its model.json

scope: {
  include: ['model1', 'model2']
}

and I make a filter REST API call with /api/model?include=model3

Turns out the requested include was never included in the serialised result because

  1. isLoopbackInclude checked for an incomplete condition, which overrode isJSONAPIInclude -> added ctx.args.filter.include to make it correct
  2. setRequestedInclude did not account for object of type { [modelName]: true } -> made it do so

abhilashmurthy avatar Jan 13 '21 10:01 abhilashmurthy

Coverage Status

Coverage remained the same at 94.554% when pulling d28e324a7f5f6d6a21f45cda61ec30018a29bf31 on abhilashmurthy:fix-requested-include-pojo into a7083aad413b3404bc1466650b20b6437983133a on digitalsadhu:master.

coveralls avatar Jan 13 '21 10:01 coveralls