You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, I am using loadQuery() to prefetch a query for another page when the user hovers over navigation items. The preloaded reference is purely to prime the relay store with the query results optimistically (I'm currently using useLazyloadQuery on those pages). The loadQuery() response is disposed in the onMouseLeave() for this button to allow it to be GCed, but currently if I hover the button again it does not fire a new query due to a fetchPolicy of 'store-or-network' (and the prefetch being retained in the store for a bit, even though I've disposed the reference). I currently use the concrete request to load this query (to avoid impacting bundle sizes, this prefetching file would do an async import for the concrete request file).
With support for @preloadable in new versions of relay, I wanted to change this pre-fetch query to just directly import the preloadable concrete request to simplify logic and avoid the async import of the large concrete request. However, I'm seeing some unexpected behavior when using it.
Issue
When using loadQuery() with a preloadable concrete request (from '..Query$parameters), repeated calls to loadQuery(env, preloadableRequest, {}, {fetchPolicy: 'store-or-network') each trigger a new network request immediately once the reference is disposed. This seems to be different behavior from a non-preloadable request, which would be satisfied by the relay store on subsequent triggers even if disposed (for some window of time at least).
I can probably delay the disposal of the prefetch to avoid these repeated network calls in my case, but I'm wondering if this is expected behavior. It seems odd for the preload query to be disposed faster than a regular query, but maybe I've missed somewhere this can be configured.
The text was updated successfully, but these errors were encountered:
Context
Currently, I am using
loadQuery()
to prefetch a query for another page when the user hovers over navigation items. The preloaded reference is purely to prime the relay store with the query results optimistically (I'm currently usinguseLazyloadQuery
on those pages). TheloadQuery()
response is disposed in theonMouseLeave()
for this button to allow it to be GCed, but currently if I hover the button again it does not fire a new query due to a fetchPolicy of 'store-or-network' (and the prefetch being retained in the store for a bit, even though I've disposed the reference). I currently use the concrete request to load this query (to avoid impacting bundle sizes, this prefetching file would do an async import for the concrete request file).With support for @preloadable in new versions of relay, I wanted to change this pre-fetch query to just directly import the preloadable concrete request to simplify logic and avoid the async import of the large concrete request. However, I'm seeing some unexpected behavior when using it.
Issue
When using
loadQuery()
with a preloadable concrete request (from'..Query$parameters
), repeated calls toloadQuery(env, preloadableRequest, {}, {fetchPolicy: 'store-or-network')
each trigger a new network request immediately once the reference is disposed. This seems to be different behavior from a non-preloadable request, which would be satisfied by the relay store on subsequent triggers even if disposed (for some window of time at least).I can probably delay the disposal of the prefetch to avoid these repeated network calls in my case, but I'm wondering if this is expected behavior. It seems odd for the preload query to be disposed faster than a regular query, but maybe I've missed somewhere this can be configured.
The text was updated successfully, but these errors were encountered: