apollo-link
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -5,2 +5,8 @@ # Change log | ||
# 1.0.5 | ||
- fix bug where context wasn't merged when setting it | ||
# 1.0.4 | ||
- export link util helpers | ||
# 1.0.3 | ||
@@ -7,0 +13,0 @@ - removed requiring query on initial execution check |
@@ -100,6 +100,6 @@ (function (global, factory) { | ||
if (typeof next === 'function') { | ||
context = next(context); | ||
context = __assign({}, context, next(context)); | ||
} | ||
else { | ||
context = __assign({}, next); | ||
context = __assign({}, context, next); | ||
} | ||
@@ -106,0 +106,0 @@ }; |
@@ -98,6 +98,6 @@ var __extends = (this && this.__extends) || (function () { | ||
if (typeof next === 'function') { | ||
context = next(context); | ||
context = __assign({}, context, next(context)); | ||
} | ||
else { | ||
context = __assign({}, next); | ||
context = __assign({}, context, next); | ||
} | ||
@@ -104,0 +104,0 @@ }; |
{ | ||
"name": "apollo-link", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Flexible, lightweight transport layer for GraphQL", | ||
@@ -5,0 +5,0 @@ "author": "Evans Hauser <evanshauser@gmail.com>", |
@@ -17,5 +17,4 @@ import * as Observable from 'zen-observable'; | ||
const setContext = () => ({ add: 1 }); | ||
describe('ApolloLink(abstract class)', () => { | ||
const setContext = () => ({ add: 1 }); | ||
describe('concat', () => { | ||
@@ -349,3 +348,49 @@ it('should concat a function', done => { | ||
}); | ||
describe('context', () => { | ||
it('should merge context when using a function', done => { | ||
const returnOne = new SetContextLink(setContext); | ||
const mock = new MockLink((op, forward) => { | ||
op.setContext(({ add }) => ({ add: add + 2 })); | ||
op.setContext(() => ({ substract: 1 })); | ||
return forward(op); | ||
}); | ||
const link = returnOne.concat(mock).concat(op => { | ||
expect(op.getContext()).toEqual({ | ||
add: 3, | ||
substract: 1, | ||
}); | ||
return Observable.of({ data: op.getContext().add }); | ||
}); | ||
testLinkResults({ | ||
link, | ||
results: [3], | ||
done, | ||
}); | ||
}); | ||
it('should merge context when not using a function', done => { | ||
const returnOne = new SetContextLink(setContext); | ||
const mock = new MockLink((op, forward) => { | ||
op.setContext({ add: 3 }); | ||
op.setContext({ substract: 1 }); | ||
return forward(op); | ||
}); | ||
const link = returnOne.concat(mock).concat(op => { | ||
expect(op.getContext()).toEqual({ | ||
add: 3, | ||
substract: 1, | ||
}); | ||
return Observable.of({ data: op.getContext().add }); | ||
}); | ||
testLinkResults({ | ||
link, | ||
results: [3], | ||
done, | ||
}); | ||
}); | ||
}); | ||
describe('Link static library', () => { | ||
@@ -352,0 +397,0 @@ describe('from', () => { |
@@ -96,5 +96,5 @@ import { getOperationName } from 'apollo-utilities'; | ||
if (typeof next === 'function') { | ||
context = next(context); | ||
context = { ...context, ...next(context) }; | ||
} else { | ||
context = { ...next }; | ||
context = { ...context, ...next }; | ||
} | ||
@@ -101,0 +101,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
90203
1903