Skip to content

Commit

Permalink
Merge pull request apollographql#1274 from tscanlin/afterware-mutations
Browse files Browse the repository at this point in the history
mutations for afterware to support retrying requests
  • Loading branch information
helfer authored Feb 9, 2017
2 parents f8e4d1e + 5e8d939 commit 4ed7557
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/transport/networkInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,15 @@ export class HTTPFetchNetworkInterface implements NetworkInterface {
options,
}: ResponseAndOptions): Promise<ResponseAndOptions> {
return new Promise((resolve, reject) => {
// Declare responseObject so that afterware can mutate it.
const responseObject = { response, options };
const queue = (funcs: any[], scope: any) => {
const next = () => {
if (funcs.length > 0) {
const f = funcs.shift();
f.applyAfterware.apply(scope, [{ response, options }, next]);
f.applyAfterware.apply(scope, [responseObject, next]);
} else {
resolve({
response,
options,
});
resolve(responseObject);
}
};
next();
Expand Down

0 comments on commit 4ed7557

Please sign in to comment.