createCollection(queryCollectionOptions({
queryClient: queryClient,
refetchInterval: 1000,
startSync: true,
staleTime: 1000,
syncMode: "eager",
queryKey: queryKey,
queryFn: async ({client}) => {
logDebug(`♻️ Refreshing data for collection ${queryKey.join(",")}`);
const response = await githubClient.conditionalRequest(apiCall, apiParams)
// Indicates no changes to the API, so we should return the existing data to indicate no changes.
if (!response) {
logDebug(`🎯 Cache hit for collection ${queryKey.join(",")}`);
return client.getQueryData<TSelected[]>(queryKey) ?? [] as TSelected[];
}
// If the response is a single object, return it as an array
logDebug(`✨ Changes detected for collection ${queryKey.join(",")}`);
// FIXME: Generalize
const result = selector(response);
return result
},
getKey: (i) => (i as any)[primaryKey],
}))
So this is my collection, and I have also subscribed to it using subscribeChanges. The first run kicks off, and toArrayWhenReady works just fine. However, I never see it refectch on either the refetchInterval or staletime. I added startSync and syncMode: eager just to see if that would help but it doesn't.
The only thing I have for a workaround is add an interval:
this.refresher = setInterval(() => {
defaultQueryClient.invalidateQueries({queryKey}, { cancelRefetch: false, throwOnError: true });
}, 1000);
and then it works kinda sorta like I expect
Is this a bug or am I missing something fundamental? I haven't added a liveQuery on top of it, I assumed the subscribeChanges would be sufficient, but even then it shouldn't matter?