@@ -7,6 +7,8 @@ import { BatchLink } from '@apollo/client/link/batch';
77import type { HttpLink } from './http-link' ;
88import { Body , Context , OperationPrinter , Request } from './types' ;
99import {
10+ convertHeadersToArray ,
11+ convertToHttpHeaders ,
1012 createHeadersWithClientAwareness ,
1113 fetch ,
1214 mergeHeaders ,
@@ -38,7 +40,7 @@ export const defaults = {
3840 */
3941export function pick < K extends keyof Omit < typeof defaults , 'batchInterval' | 'batchMax' > > (
4042 context : Context ,
41- options : HttpBatchLink . Options ,
43+ options : Omit < HttpBatchLink . Options , 'headers' > ,
4244 key : K ,
4345) : ReturnType < typeof prioritize < Context [ K ] | HttpBatchLink . Options [ K ] | ( typeof defaults ) [ K ] > > {
4446 return prioritize ( context [ key ] , options [ key ] , defaults [ key ] ) ;
@@ -161,7 +163,9 @@ export class HttpBatchLinkHandler extends ApolloLink {
161163 return operations . reduce (
162164 ( headers : HttpHeaders , operation : ApolloLink . Operation ) => {
163165 const { headers : contextHeaders } = operation . getContext ( ) ;
164- return contextHeaders ? mergeHeaders ( headers , contextHeaders ) : headers ;
166+ return contextHeaders
167+ ? mergeHeaders ( headers , convertToHttpHeaders ( contextHeaders ) )
168+ : headers ;
165169 } ,
166170 createHeadersWithClientAwareness ( {
167171 headers : this . options . headers ,
@@ -187,8 +191,7 @@ export class HttpBatchLinkHandler extends ApolloLink {
187191 return Math . random ( ) . toString ( 36 ) . substring ( 2 , 11 ) ;
188192 }
189193
190- const headers =
191- context . headers && context . headers . keys ( ) . map ( ( k : string ) => context . headers ! . get ( k ) ) ;
194+ const headers = convertHeadersToArray ( context . headers ) ;
192195
193196 const opts = JSON . stringify ( {
194197 includeQuery : context . includeQuery ,
@@ -199,7 +202,7 @@ export class HttpBatchLinkHandler extends ApolloLink {
199202 return prioritize ( context . uri , this . options . uri , '' ) + opts ;
200203 }
201204
202- public request (
205+ public override request (
203206 op : ApolloLink . Operation ,
204207 forward : ApolloLink . ForwardFunction ,
205208 ) : Observable < ApolloLink . Result > {
0 commit comments