apollo-link-token-refresh icon indicating copy to clipboard operation
apollo-link-token-refresh copied to clipboard

Make response object a generic for other fetch mechanisms

Open Rocamonde opened this issue 4 years ago • 1 comments

Currently, fetchAccessToken must return a Promise<Response> object. This works fine if the token is fetched using fetch via REST. However, my API also uses GraphQL for refreshing tokens (as I believe many GraphQL APIs would do) and I have configured a separate Apollo client with a few helper functions that execute the refresh token mutation.

I have managed to make it work by overriding the type checker (the actual logic of the code is not opinionated about this if you implement handleResponse), but I think it would be better if I could specify a custom type so I don't have to do this.

In general, users may obtain their refresh token as a result of calling a variety of functions that might not return a response promise, and I think it could be useful to make the return a generic.

I am happy to submit a pull request for this if you would consider accepting this @newsiberian .

Rocamonde avatar Jan 28 '21 14:01 Rocamonde

Sounds reasonable

newsiberian avatar Jan 29 '21 03:01 newsiberian