Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
)
.then((results: FetchResult[]) => {
(emittedResponse = true) && notifier.emit('res', results);
// we have data and can send it to back up the link chain
observer.next(results);
observer.complete();
return results;
})
.catch(err => {
emittedResponse || notifier.emit('res', err);
observer.error(err);
});
});
this.batcher = new BatchLink({
batchInterval: options.batchInterval,
batchHandler
});
}
const batchKey = () => 'hi';
const batchHandler = operations => Observable.of();
const batch = new LocalScopedLink({
batchInterval: 20,
batchMax: 20,
batchKey,
batchHandler,
});
const {
batchInterval,
batchMax,
batchKey: batchKeyArg,
} = BatchLink.mock.calls[0][0];
expect(batchInterval).toBe(20);
expect(batchMax).toBe(20);
expect(batchKeyArg()).toEqual(batchKey());
});
batchKey ||
((operation: Operation) => {
const context = operation.getContext();
const contextConfig = {
http: context.http,
options: context.fetchOptions,
credentials: context.credentials,
headers: context.headers,
};
//may throw error if config not serializable
return selectURI(operation, uri) + JSON.stringify(contextConfig);
});
this.batcher = new BatchLink({
batchInterval: this.batchInterval,
batchMax: this.batchMax,
batchKey,
batchHandler,
});
}
return () => {
if (!sub.closed) {
sub.unsubscribe();
}
};
});
};
const batchKey =
options.batchKey ||
((operation: Operation) => {
return this.createBatchKey(operation);
});
this.batcher = new BatchLink({
batchInterval: this.batchInterval,
batchMax: this.batchMax,
batchKey,
batchHandler,
});
}
id: queryMap[queryKey],
};
});
apolloFetch(printedOperations)
.then((data) => {
observer.next(data);
observer.complete();
})
.catch(observer.error.bind(observer));
});
};
const apolloLink = new BatchHttpLink();
return Object.assign(apolloLink, {
batcher: new BatchLink({
batchInterval: apolloLink.batchInterval,
batchMax: apolloLink.batchMax,
batchHandler: batchHandler.bind(apolloLink),
}),
});
};