Open amacleay opened 6 years ago
Hi, @amacleay, did you try to do something like this?:
accessTokenField: 'refreshedSession', // Your object name with `accessToken` and
// `expirationTimestamp` that returned by fetch
fetchAccessToken: fetch(...),
handleResponse: (_, __) => (response: typeYouNeed) => {
...
return {
accessToken,
expirationTimestamp
};
},
handleFetch: ({ accessToken, expirationTimestamp }) => saveToken
That would certainly work as I've laid out the issue.
In actual fact, though, I need to use a function in fetchAccessToken
that doesn't expose the fetch
API at all: my refreshSession
function is actually wrapping a call to apollo-client
Can you make a PR that allows to avoid cases like yours?
I am trying to use apollo-link-token-refresh in a typescript project. In this project, we are using a library function to make the access token refresh request, and that library function does not expose the
Fetch
API underneath:I believe I should be able to use apollo-link-token-refresh without casting to
any
or using any other type hacks. Perhaps TokenRefreshLink should have an optional type parameter.Workaround: force my session response to be of a modified
Response
type: