RamyElkest / apollo-chat-api

A chat API service over graphql with apollo
MIT License
2 stars 2 forks source link

dataloader cached promises always pending #85

Open marcosrmendezthd opened 7 years ago

marcosrmendezthd commented 7 years ago

Hi,

I've followed the same pattern for the connector in my own code. What I'm noticing though is that the requests never get to use the cache because the promises seem to always be pending.

Are you seeing this or perhaps this is an error in my code?

` return Promise.all(urls.map((url) => {

        console.log("fetching", url);
        const cachedRes = this.eTagCache[url];

        if (cachedRes && cachedRes.eTag) {
            options.headers['If-None-Match'] = cachedRes.eTag;
        }
        console.log("cache", this.loader); // cached promises are always pending

        return new Promise((resolve, reject) => {
            this.rp({
                uri: url,
                ...options,
            }).then((response) => { resolve(response) ... }.catch((err) => {reject(err) ... }`