Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const processOfflineQuery = (operation: Operation, theStore: Store) => {
const { [NORMALIZED_CACHE_KEY]: normalizedCache = {} } = theStore.getState();
const { query, variables } = operation;
const { cache } = operation.getContext();
const store = defaultNormalizedCacheFactory(normalizedCache);
const data = cache.storeReader.readQueryFromStore({
store,
query,
variables,
});
return data;
}
});
}
baseLastSyncTimestamp = Date.now() - BUFFER_MILLISECONDS;
boundUpdateLastSync(store, { hash, baseLastSyncTimestamp });
} else {
try {
if (enquededMutations.length === 1) {
boundSaveSnapshot(store, client.cache);
}
const {
[METADATA_KEY]: { snapshot: { cache: cacheSnapshot } },
} = store.getState();
const data = (cacheProxy as any).storeReader.readQueryFromStore({
store: defaultNormalizedCacheFactory(cacheSnapshot),
query: addTypenameToDocument(query),
variables,
});
cacheProxy.writeQuery({ query, variables, data });
} catch (error) {
logger('Error reading/writting baseQuery from store', error);
}
}
}
//#endregion
//#region Delta query
if (deltaQuery && deltaQuery.query && !skipBaseQuery) {
logger('Skipping deltaQuery');
}