Describe the bug
Overriding the used fetch client in Apollo Client with ky (which is fetch compatible) leads to failures in the request matching algorithm. I'm using ky to have a central (single source of truth) for setting headers like Authorization on all request through a beforeRequest hook
const fetchClient = ky.create({
hooks: {
beforeRequest: [
(request) => {
request.headers.set('Authorization', `Bearer ${access_token}`);
},
],
},
});
const httpLink = new HttpLink({
uri: '',
fetch: fetchClient,
});
Expected behavior
Graphql requests still get matched.
Additional context
Add any other context about the problem here.
I've inspected the difference between the fetch and the ky calls (chrome.webRequest.WebRequestBodyDetails):
ky
{
"documentId": "50EF69BBAF89263539823056234B884C",
"documentLifecycle": "active",
"frameId": 0,
"frameType": "outermost_frame",
"initiator": "http://localhost:3000",
"method": "POST",
"parentFrameId": -1,
"requestBody": {
"error": "Unknown error."
},
"requestId": "143649",
"tabId": 420505696,
"timeStamp": 1772205719634.835,
"type": "xmlhttprequest",
"url": "..."
}
fetch
{
"documentId": "565CADCE046FB1B0AD9B3329B18A8216",
"documentLifecycle": "active",
"frameId": 0,
"frameType": "outermost_frame",
"initiator": "http://localhost:3000",
"method": "POST",
"parentFrameId": -1,
"requestBody": {
"raw": [
{
"bytes": {}
}
]
},
"requestId": "138471",
"tabId": 420505696,
"timeStamp": 1772205538801.859,
"type": "xmlhttprequest",
"url": "..."
Describe the bug
Overriding the used fetch client in Apollo Client with ky (which is fetch compatible) leads to failures in the request matching algorithm. I'm using ky to have a central (single source of truth) for setting headers like Authorization on all request through a beforeRequest hook
Expected behavior
Graphql requests still get matched.
Additional context
Add any other context about the problem here.
I've inspected the difference between the fetch and the ky calls (
chrome.webRequest.WebRequestBodyDetails):ky
fetch