How to use the apollo-cache-inmemory.defaultNormalizedCacheFactory function in apollo-cache-inmemory

To help you get started, we’ve selected a few apollo-cache-inmemory examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github awslabs / aws-mobile-appsync-sdk-js / packages / aws-appsync / src / link / offline-link.ts View on Github external
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;
}
github awslabs / aws-mobile-appsync-sdk-js / packages / aws-appsync / src / deltaSync.ts View on Github external
});
                }

                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');
        }