slicknode-apollo-link
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -16,2 +16,3 @@ "use strict"; | ||
const graphql_tag_1 = __importDefault(require("graphql-tag")); | ||
const sinon_1 = __importDefault(require("sinon")); | ||
const SlicknodeLink_1 = __importStar(require("../SlicknodeLink")); | ||
@@ -24,9 +25,10 @@ // tslint:disable no-unused-expression | ||
}; | ||
const nextLink = sinon_1.default.stub().callsFake((e) => { | ||
return new apollo_link_1.Observable((observer) => { | ||
observer.next({ data }); | ||
}); | ||
}); | ||
const slicknodeLink = apollo_link_1.ApolloLink.from([ | ||
new SlicknodeLink_1.default(), | ||
new apollo_link_1.ApolloLink((e) => { | ||
return new apollo_link_1.Observable((observer) => { | ||
observer.next({ data }); | ||
}); | ||
}), | ||
new apollo_link_1.ApolloLink(nextLink), | ||
]); | ||
@@ -42,2 +44,3 @@ const query = graphql_tag_1.default `{test}`; | ||
chai_1.expect(result.data).to.equal(data); | ||
chai_1.expect(nextLink.calledOnce).to.be.true; | ||
done(); | ||
@@ -695,9 +698,12 @@ }, | ||
const slicknodeLink = new SlicknodeLink_1.default(); | ||
const dataLoaderStub = sinon_1.default.stub(); | ||
const nextLink = sinon_1.default.stub().callsFake(() => { | ||
return new apollo_link_1.Observable((observer) => { | ||
dataLoaderStub(); | ||
observer.next({ data }); | ||
}); | ||
}); | ||
const link = apollo_link_1.ApolloLink.from([ | ||
slicknodeLink, | ||
new apollo_link_1.ApolloLink(() => { | ||
return new apollo_link_1.Observable((observer) => { | ||
observer.next({ data }); | ||
}); | ||
}), | ||
new apollo_link_1.ApolloLink(nextLink), | ||
]); | ||
@@ -728,2 +734,4 @@ const query = graphql_tag_1.default `mutation LoginMutation { | ||
chai_1.expect(slicknodeLink.getRefreshTokenExpires()).to.be.below(authTokenSet.refreshTokenLifetime * 1000 + Date.now() + 1); | ||
chai_1.expect(nextLink.calledOnce).to.be.true; | ||
chai_1.expect(dataLoaderStub.calledOnce).to.be.true; | ||
done(); | ||
@@ -730,0 +738,0 @@ }, |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -69,3 +70,3 @@ }); | ||
operation.setContext(({ headers }) => ({ | ||
headers: Object.assign({}, (headers || {}), authHeaders), | ||
headers: Object.assign(Object.assign({}, (headers || {})), authHeaders), | ||
})); | ||
@@ -124,4 +125,14 @@ const definitions = operation.query.definitions; | ||
// Add result listeners for token and logout processing | ||
resultListeners.map((listener) => nextObservable.subscribe(listener)); | ||
nextObservable.subscribe(observer); | ||
nextObservable.subscribe({ | ||
complete() { | ||
observer.complete(); | ||
}, | ||
error(errorValue) { | ||
observer.error(errorValue); | ||
}, | ||
next(value) { | ||
resultListeners.forEach((listener) => listener(value)); | ||
observer.next(value); | ||
}, | ||
}); | ||
}) | ||
@@ -128,0 +139,0 @@ .catch((error) => { |
{ | ||
"name": "slicknode-apollo-link", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"repository": "https://github.com/slicknode/slicknode-apollo-link.git", | ||
@@ -5,0 +5,0 @@ "author": "Ivo Meißner <info@overtronic.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
93006
1362
0