How to handle HTML response type in graphql

I am using react, apollo and graphql in my application.

Our FE is connected to a gateway that federate multiple API together, including some graphQL ones. The idea is, the FE query the gateway, the gateway call the appropriated APIs and return the response from them.

The gateway currently handle some basic error, like unauthorized clients etc…

The issue I face is, since our gateway is generic and not bound to graphql only, the error it return (for exemple when I query a graphql api but the token is expired) some default error that use

content-type: text/html; charset=utf-8

For example

    <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>UnauthorizedError: No authorization token was found<br> &nbsp; &nbsp;at new UnauthorizedError (/home/node/app/node_modules/express-jwt/dist/errors/UnauthorizedError.js:22:28)<br> &nbsp; &nbsp;at /home/node/app/node_modules/express-jwt/dist/index.js:113:39<br> &nbsp; &nbsp;at step (/home/node/app/node_modules/express-jwt/dist/index.js:33:23)<br> &nbsp; &nbsp;at Object.next (/home/node/app/node_modules/express-jwt/dist/index.js:14:53)<br> &nbsp; &nbsp;at /home/node/app/node_modules/express-jwt/dist/index.js:8:71<br> &nbsp; &nbsp;at new Promise (&lt;anonymous&gt;)<br> &nbsp; &nbsp;at __awaiter (/home/node/app/node_modules/express-jwt/dist/index.js:4:12)<br> &nbsp; &nbsp;at middleware (/home/node/app/node_modules/express-jwt/dist/index.js:66:16)<br> &nbsp; &nbsp;at /home/node/app/node_modules/express-unless/dist/index.js:50:13<br> &nbsp; &nbsp;at Generator.next (&lt;anonymous&gt;)</pre>
</body>
</html>

Now, I was expecting to retrieve a networkError 401 in my apollo Link onError, but instead, it seems it fail to parse the body and the only thing I get is a

[Network error]: TypeError: Failed to fetch

This is because graphql try to parse the response, but crash due to the body being an HTML page, and I lose the scope and code of the error. I tried to retrieve that statusCode 401, but I haven"t succeded

Is there a way to allow graphql to ignore certain context type to be parsed ?