Skip to content
This repository was archived by the owner on Sep 10, 2019. It is now read-only.

Commit f3c2c3f

Browse files
committed
fix(GraphQLConnector): separate headers and body when resolving with both
1 parent 37872f0 commit f3c2c3f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/GraphQLConnector.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,11 @@ export default class GraphQLConnector {
8282
const hasCache = this.enableCache && this.getCached(key, resolve, reject);
8383

8484
this.request(this.getRequestConfig(uri))
85-
.then(response => {
86-
const data = options.resolveWithHeaders
87-
? { ...response.headers, ...response.body }
88-
: response.body;
85+
.then(({ headers, body, statusCode }) => {
86+
const data = options.resolveWithHeaders ? { headers, body } : body;
8987

9088
// If the data came through alright, cache it.
91-
if (response.statusCode === 200) {
89+
if (statusCode === 200) {
9290
this.addToCache(key, data);
9391
}
9492

test/GraphQLConnector.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,12 @@ describe('GraphQLConnector', () => {
185185
.getRequestData('https://example.com', { resolveWithHeaders: true })
186186
.then(result => {
187187
expect(result).toEqual({
188-
'content-type': 'application/json',
189-
test: 'body',
188+
headers: {
189+
'content-type': 'application/json',
190+
},
191+
body: {
192+
test: 'body',
193+
},
190194
});
191195
expect(tc.redis.setex).toHaveBeenCalled();
192196
});

0 commit comments

Comments
 (0)