@@ -8,6 +8,8 @@ import { BatchLink } from '@apollo/client/link/batch';
88import type { HttpLink } from './http-link' ;
99import { Body , Context , OperationPrinter , Request } from './types' ;
1010import {
11+ convertHeadersToArray ,
12+ convertToHttpHeaders ,
1113 createHeadersWithClientAwareness ,
1214 fetch ,
1315 mergeHeaders ,
@@ -74,7 +76,7 @@ export const defaults = {
7476 */
7577export function pick < K extends keyof Omit < typeof defaults , 'batchInterval' | 'batchMax' > > (
7678 context : Context ,
77- options : HttpBatchLink . Options ,
79+ options : Omit < HttpBatchLink . Options , 'headers' > ,
7880 key : K ,
7981) : ReturnType < typeof prioritize < Context [ K ] | HttpBatchLink . Options [ K ] | ( typeof defaults ) [ K ] > > {
8082 return prioritize ( context [ key ] , options [ key ] , defaults [ key ] ) ;
@@ -201,7 +203,9 @@ export class HttpBatchLinkHandler extends ApolloLink {
201203 return operations . reduce (
202204 ( headers : HttpHeaders , operation : ApolloLink . Operation ) => {
203205 const { headers : contextHeaders } = operation . getContext ( ) ;
204- return contextHeaders ? mergeHeaders ( headers , contextHeaders ) : headers ;
206+ return contextHeaders
207+ ? mergeHeaders ( headers , convertToHttpHeaders ( contextHeaders ) )
208+ : headers ;
205209 } ,
206210 createHeadersWithClientAwareness ( {
207211 headers : this . options . headers ,
@@ -227,8 +231,7 @@ export class HttpBatchLinkHandler extends ApolloLink {
227231 return Math . random ( ) . toString ( 36 ) . substring ( 2 , 11 ) ;
228232 }
229233
230- const headers =
231- context . headers && context . headers . keys ( ) . map ( ( k : string ) => context . headers ! . get ( k ) ) ;
234+ const headers = convertHeadersToArray ( context . headers ) ;
232235
233236 const opts = JSON . stringify ( {
234237 includeQuery : context . includeQuery ,
@@ -239,7 +242,7 @@ export class HttpBatchLinkHandler extends ApolloLink {
239242 return prioritize ( context . uri , this . options . uri , '' ) + opts ;
240243 }
241244
242- public request (
245+ public override request (
243246 op : ApolloLink . Operation ,
244247 forward : ApolloLink . ForwardFunction ,
245248 ) : Observable < ApolloLink . Result > {
0 commit comments