Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apis that have their requests cached dont need to make unnecessary auth token fetches #7814

Open
samstitt opened this issue Jan 5, 2024 · 0 comments

Comments

@samstitt
Copy link

samstitt commented Jan 5, 2024

Issue

You have API-A that as part of its request requires an auth token from API-B, Once you get a response for API-A you cache the payload for 24 hours in something like redis.

A new request comes in that requires API-A, However you don't want to request API-B again if its in the cache. It would be good if there was a restdatasource hook that would only be called if its not in the cache to allow you to fetch auth tokens before sending the request again.

the flow would be something like

apollo drawio

because the request API-A has a dependency on API-B you have to fetch it before making the request to API-A even if API-A is in the cache because the cache check is only done on fetch meaning you have to build the full request prior to sending.

you could in theory manually checking redis via the context is possible but I am sure there are a few usecases for a cache-miss hook that could be abstracted to a function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant