Apollo-link: BatchHttpLink does not provide exposed response headers

Created on 18 May 2018  路  2Comments  路  Source: apollographql/apollo-link

I have this afterware that was working great till we implemented import { BatchHttpLink } from 'apollo-link-batch-http'. Now I no longer have access to the response headers.

//const httpLink = createHttpLink(
//  { uri: GRAPHQL_ENDPOINT, credentials: 'same-origin' }
//)

 const httpLink = new BatchHttpLink({
   uri: GRAPHQL_ENDPOINT,
   credentials: 'same-origin'
 })

const afterwareLink = new ApolloLink((operation, forward) => {
  return forward(operation).map(response => {
    const context = operation.getContext()
    const {
      response: { headers }
    } = context

    if (headers) {
      const logout = headers.get('logout')

      if (logout) {
        LocalStorage.removeItem('access_token')
      }
    }
    return response
  })
})

const link = ApolloLink.from([
  catchErrorLink,
  middlewareLink,
  afterwareLink,
  httpLink
])

The only property that lives on response is "data" holding query results.

Expected Behavior

I would like the BatchHttpLink to return response headers that are exposed by the server. My server is properly exposing it.

Most helpful comment

@mikebm I've created a PR #852. Hoping this will get merged in although seems unlikely

All 2 comments

Any ETA on when this might get fixed? This is preventing me from being able to use it as well.

@mikebm I've created a PR #852. Hoping this will get merged in although seems unlikely

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maktouch picture maktouch  路  5Comments

steffenmllr picture steffenmllr  路  4Comments

ChenRoth picture ChenRoth  路  4Comments

j3ddesign picture j3ddesign  路  3Comments

zsolt-dev picture zsolt-dev  路  4Comments