graphql-mesh
graphql-mesh copied to clipboard
Combining transformations and response cache plugin causes mangled responses
Issue workflow progress
Progress of the issue based on the Contributor Workflow
- [ ] 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox
Make sure to fork this template and run
yarn generate
in the terminal.Please make sure Mesh package versions under
package.json
matches yours.
- [ ] 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 combinations of applying transformations and using Response cache plugin, causes mangled responses. Commenting out either transformations or caching gives the correct response. This used to work up to the following versions contained in (yarn.lock.txt)
To Reproduce Steps to reproduce the behavior: Unfortunately it's not possible to submit a reproducible sandbox as we're integrating with a 3rd party subgraph ContentStack which is not publicly accessible.
Query:
query AllSizeGuides {
cms{
all_size_guide(limit: 1, skip: 0, locale: "fr-nl") {
total,
items {
chunk_id,
}
}
}
}
Expected response:
{
"data": {
"__typename": "Query",
"cms": {
"__typename": "Query",
"all_size_guide": {
"__typename": "CS_AllSizeGuide",
"total": 121,
"items": [
{
"__typename": "CS_SizeGuide",
"chunk_id": [
80007203
]
}
]
}
}
}
}
Mangled Response:
{
"data": {
"__gqtld0__": "Query",
"__gqtld1__": {
"total": 121,
"items": [
{
"chunk_id": [
80007203
]
}
]
}
}
}
Expected behaviour
Environment:
- OS: MacOs 14 & all test/production env using docker containers
- Mesh dependencies:
"@graphql-mesh/cache-redis": "0.95.11",
"@graphql-mesh/cli": "0.87.14",
"@graphql-mesh/graphql": "0.95.7",
"@graphql-mesh/plugin-prometheus": "0.95.10",
"@graphql-mesh/plugin-response-cache": "0.95.9",
"@envelop/response-cache":"5.1.0",
"@graphql-mesh/plugin-snapshot": "^0.95.7",
"@graphql-mesh/transform-encapsulate": "0.95.10",
"@graphql-mesh/transform-federation": "0.95.8",
"@graphql-mesh/transform-prefix": "0.95.8",
"@graphql-mesh/transform-rename": "0.95.8",
"graphql": "16.8.1",
"prom-client": "15.0.0"
- NodeJS: v18.18.1
Additional context
While configuring snapshot plugin, noticed additional file being snapshoted while performing the same query: mangled_snapshots.zip as opposed to the snapshots when a valid response is returned: correct_snapshots.zip
I'm facing this issue too, was able to reproduce by using the response-cache plugin and the encapsulate transform with a single source. If there are 2 or more sources the issue is no longer present:
Sorry for the late response! It doesn't happen on the single source because we don't apply stitching and forward requests directly to the single source's executor, and when cache hits, response cache plugin stops execution with result without applying the transforms after. So this causes you get the raw result. This would be solved after this PR gets merged; https://github.com/n1ru4l/envelop/pull/2093
@ardatan, I just upgraded all libraries to the latest releases and the bug still exists. My current dependencies are:
"dependencies": {
"@graphql-mesh/cache-redis": "^0.96.0",
"@graphql-mesh/cli": "^0.88.5",
"@graphql-mesh/graphql": "^0.96.0",
"@graphql-mesh/plugin-prometheus": "^0.96.0",
"@graphql-mesh/transform-encapsulate": "^0.96.0",
"@graphql-mesh/transform-federation": "^0.96.0",
"@graphql-mesh/transform-prefix": "^0.96.0",
"@graphql-mesh/transform-rename": "^0.96.0",
"graphql": "^16.8.1",
"prom-client": "^15.0.0"
}