-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Rest DataSource Caching Errors #5608
Comments
Seems the issue is with memoization. Based on some points noted in this bug I added:
This seems to ensure that error responses are not held onto indefinitely. A few takeaways:
My experience shows that across separate requests, the 401 response continues to be served up regardless. Cheers |
Where/how do you initialize your data sources? AFAIK they need to be inside the const app = new ApolloServer({
schema: executableSchema,
dataSources: () => ({
api: new MyApi(),
}),
}); If you do something like this the data source will only be created once, meaning memoization won't reset between requests const dataSources = {
api: new MyApi(),
};
const app = new ApolloServer({
schema: executableSchema,
dataSources: () => dataSources,
}); |
@alexandernanberg is correct: data sources are per-request. If the issue here is about long-lived data sources, then it should be closed. If this is a misunderstanding, happy to reopen. |
I'm experiencing a similar issue as #1481. However, I have the latest rev:
"apollo-datasource-rest": "^3.1.1"
and it is clearly caching HTTP errors. Is there anyway to control the cache on a per-request level?In my situation, our JWT auth expires and the subsequent call returns unauth 401. The code immediately requests a new JWT vi the login endpoint, but cannot resolve the original request because it has cached the 401 response.
The text was updated successfully, but these errors were encountered: