generated from apollographql/typescript-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Cached REST-Response does not contain URL #35
Comments
glasser
added a commit
that referenced
this issue
Dec 3, 2022
Previously, the `url` on the `FetcherResponse` returned from an HTTPCache would be set properly if this was an actual fetch, but set to '' if it were read from the cache. This issue was introduced in apollographql/apollo-server#1362 (as part of the initial creation of RESTDataSource) as part of allowing for custom cache keys. Fixes #35.
glasser
added a commit
that referenced
this issue
Dec 5, 2022
Previously, the `url` on the `FetcherResponse` returned from an HTTPCache would be set properly if this was an actual fetch, but set to '' if it were read from the cache. This issue was introduced in apollographql/apollo-server#1362 (as part of the initial creation of RESTDataSource) as part of allowing for custom cache keys. Fixes #35.
Cheers! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use
apollo-datasource-rest
to cache responses from remote REST-APIs. Responses that have a 404 status get cached and thus read from cached on subsequent calls to that same endpoint. This is fine, until the error for the request gets created. The first request - the one that actually hit the remote and not the cache - creates an error like this:The important bit is the
url
-field telling us which exact request failed. The actual issue lies in the second request - the one that hits the cache -, which creates the following error:As you can see, the
url
-field is missing. Interestingly enough, this only happens if i set attl
in theRequestInit
object I pass to the datasource. I prepared a small reproduction for this issue: https://codesandbox.io/s/little-microservice-hm0svI analyzed the source and believe the line causing the issue is this one: https://github.com/apollographql/apollo-server/blob/c177acd7959aaf516f8ac814f1a6bb2e6d3ed2e6/packages/apollo-datasource-rest/src/HTTPCache.ts#L60
Before spending too much time looking for possible solutions, I wanted to make sure that this is in fact an issue and not something you actually intended because of some piece of information that I'm currently missing.
The text was updated successfully, but these errors were encountered: