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],
}))
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],
}))