graphql-hive / graphql-hive/envelop
[useResponseCache] Caching not working as expected when using federation + gateway
- Dominant language
- No language data
- Stars
- 827
- Forks
- 132
- PR merge metrics
- No merged PRs in 30d
Description
### Issue workflow progress
_Progress of the issue based on the
[Contributor Workflow](https://github.com/the-guild-org/Stack/blob/master/CONTRIBUTING.md#a-typical-contributor-workflow)_
- [x] 1. The issue provides a
[minimal reproduction](https://en.wikipedia.org/wiki/Minimal_reproducible_example) available on
[Stackblitz](https://stackblitz.com/fork/node).
- _Please install the latest `@envelop/*` packages that you are using._
- _Please make sure the reproduction is as small as possible._
- [ ] 2. A failing test has been provided
- [ ] 3. A local solution has been provided
- [ ] 4. A pull request is pending review
---
**Describe the bug**
The caching via plugin `useResponseCache` is not working as expected when used in the gateway of a federated service. The cache does not store ObjectTypes of GraphQL at all, but only the etag call.
**To Reproduce** Steps to reproduce the behavior:
1. Setup a federated service gateway.
2. Implement the `useResponseCache` plugin.
3. Perform GraphQL queries that should be cached.
4. Observe that only the etag calls are cached, but ObjectTypes are not.
**Expected behavior**
The cache should store ObjectTypes of GraphQL responses, ensuring that repeated queries retrieve data from the cache as expected.
**Environment:**
- OS: macOS
- NodeJS: v20.12.2
- `@envelop/*` versions:
"@envelop/response-cache": "^6.1.2"
**Additional context**
A reproducible repo is provided here: [Stackblitz Reproduction](https://stackblitz.com/~/github.com/vinaybedre/envelop-response-cache-bug)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.