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

Combining transformations and response cache plugin causes mangled responses #6272

Closed
4 tasks
bobjana opened this issue Nov 13, 2023 · 3 comments
Closed
4 tasks
Labels
bug Something isn't working stage/1-reproduction A reproduction exists

Comments

@bobjana
Copy link

bobjana commented Nov 13, 2023

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

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.

mesh-config.txt

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

@bitrvmpd
Copy link

bitrvmpd commented Nov 15, 2023

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:

@ardatan
Copy link
Owner

ardatan commented Nov 23, 2023

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;
n1ru4l/envelop#2093

@bobjana
Copy link
Author

bobjana commented Feb 22, 2024

@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"
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stage/1-reproduction A reproduction exists
Projects
None yet
Development

No branches or pull requests

4 participants