import { DecoderDictionaryStore } from 'deltaflate-decode'; import { ApolloCache } from 'apollo-cache'; export class GraphQlDecoderDictionaryStore implements DecoderDictionaryStore { cache: ApolloCache; constructor(cache: ApolloCache) { this.cache = cache; } read(): Promise> { return Promise.resolve([this.cache.extract()]); } // add GET query support async write(decodedResponse: Response): Promise { const decodedBody = await decodedResponse.clone().json(); this.cache.restore(decodedBody); } } export default GraphQlDecoderDictionaryStore;