Closed HymanZHAN closed 1 month ago
Hi @HymanZHAN fetchEntries is not part of the recommended API to tweak data, it should however be called everytime data needs to be fetched.
Regarding the different hooks / method what part of the documentation do you find lacking ? All the recommended hooks are described with their signature and some details so i'm not sure what else you would expect.
Method not documented are not documented for a reason, consider them not public.
It says in the documentation:
The entity interface allow you then to access the standard function (addEntry, fetchEntries, ...) to manipulate the mockdata of the application.
Hence I assumed fetchEntries
is a standard extension point, and looked for docs for fetchEntries
but found rarely anything.
So regarding tweaking data, if I want to dynamically add some virtual properties to the response when requested, which normally would be done in the @After(event = CqnService.EVENT_READ
in the a real CAP Java backend, does the mock server provide such extension point? Or it's preferred to prepare all such stuff in the mock data JSON files?
Currently i don't think we have a good hook for that kind of scenario.
fetchEntries
should technically be sufficient but there are case where this might not be called, and it would also not consider the potential $expand and $select that were applied.
We can turn this into a requirement if you're interested in such a hook
We can turn this into a requirement if you're interested in such a hook
That'd be great, thanks. For now, we will have to add all the virtual fields to the mock data JSONs to avoid missing properties for UI controls and the Failed to drill down to property xxx
error.
Hello @HymanZHAN there is now a new hook onAfterRead
which can be used to tweak the result before retuning it to the frontend
async onAfterRead(data: object, _odataRequest: ODataRequest): Promise
Thanks, I will check it out.
Issue Description
In our OPA, we have to mock some backend logic and we are doing this in the
fetchEntries
method, treating it like an@After(event = CqnService.EVENT_READ, entity = LibraryElement_.CDS_NAME)
hook. However, when debugging our tests, we are quite confused about the timing offetchEntries
. It seems that when changing filters on the ListReport page, this method is never invoked. Is that the expected behavior?Also, could the team provide a more detailed documentation on different hooks/methods that we can override? Right now the documentation provides little explanation...
Issue Type