Is there a way to overridde the checkAndParseHttpResponse method?
terribleuserofapollo opened this issue · 1 comments
I'm using apollo-link (v 1.2.3), as well as apollo-link-http (v 1.5.5)
I'm creating a combination of httpLink and Apollo link in my service(gateway) in order to communicate with my underlying micro-service. My micro-service returns response in the GraphQL format.
However for large responses, it is taking a long time to return the response. I narrowed down the issue being a JSON.parse() being called for the response from the microservice.
Is there a way to avoid the JSON.parse() which is done in parseAndCheckHttpResponse(operation) at line 7, since the underlying service will always return JSON format?
return new Observable(observer => {
fetcher(chosenURI, options)
.then(response => {
operation.setContext({ response });
return response;
})
.then(parseAndCheckHttpResponse(operation))
.then(result => {
observer.next(result);
observer.complete();
return result;
})
.catch(err => {
if (err.name === 'AbortError') return;
if (err.result && err.result.errors && err.result.data) {
observer.next(err.result);
}
observer.error(err);
});
Apologies for the formatting, this is my first post.
Thank you @dylanwulf for suggesting the edit.
To format multiple lines of code, surround the code with triple-backticks:
```
const hello = () => console.log('Hello world!');
hello();
```
You can also specify the language to get syntax highlighting:
```js
const hello = () => console.log('Hello world!');
hello();
```
Result:
const hello = () => console.log('Hello world!');
hello();