Apollo-link: Reading Headers With Afterware

Created on 27 Dec 2017  ·  4Comments  ·  Source: apollographql/apollo-link

I'm looking to add afterware that takes the headers from a query and adds them to localstorage. Right now I'm finding a lot of the opposite; middleware taking a token from localstorage and adding it to a query. Anybody have experience with using headers in afterware? Thanks

question

Most helpful comment

its solved, you have to update to apollo-link "apollo-link": "^1.0.7", and use code like

https://github.com/benawad/slack-clone-client/blob/31_fix_auto_refresh_of_jwt_tokens/src/apollo.js#L18

but still we have issue with https://github.com/apollographql/apollo-angular/tree/master/packages/apollo-angular-link-http in response i see headers from request only

All 4 comments

its solved, you have to update to apollo-link "apollo-link": "^1.0.7", and use code like

https://github.com/benawad/slack-clone-client/blob/31_fix_auto_refresh_of_jwt_tokens/src/apollo.js#L18

but still we have issue with https://github.com/apollographql/apollo-angular/tree/master/packages/apollo-angular-link-http in response i see headers from request only

@agborkowski
I can get response headers, but
any chance to pass the headers out?
for example to the query response?

I tried, but not work

Thank you @agborkowski for the links! (This pun never gets old 😆)

@ash0080 you can add them to the response before returning them from the map call, for example here

@evans I'm quite sure this does not work at least it doesn't in apollo-boost:

you can add them to the response before returning them from the map call, for example here

EDIT: Nevermind I found this apollographql/apollo-client#1419

Was this page helpful?
0 / 5 - 0 ratings