Open cbou opened 1 month ago
There is currently no way to get fetchOptions propagated to subsequent requests. And I doubt that it would be a good idea to have these propagated by default. You can e.g. opt-out of automatic reference resolving (by setting the depth to zero) and do then the resolving yourself (including your desired options).
But we may accept a patch as long as it is non-breaking (ie with an opt-in flag).
In headless situation, caching is very important, especially for requests triggered to the backend.
In my project, I use fetchByFilter to get some objects. To prevent making too much request to the backend I rely on the cache mechanism of NextJS: https://nextjs.org/docs/app/building-your-application/data-fetching I pass a fetchOptions object with the information about the caching to
fetchByFilter
. e.g.:NextJS will cache the response of the fetch for one hour. The next calls will be served from the cache instead of from the backend. It works well.
If the returned objects contains some DatasetReference. Sub requests will be triggered internally by the
fsxa-api
library. However thefetchOptions
param is lost and not passed by the originalfetchByFilter
call.This makes caching of sub request impossible.
I was able to check that by adding some extra logging.
FSXARemoteApi.js
The produced log:
Is there a way to make sure the
fetchOptions
is pass to subfetchByFilter
calls?