ardatan / graphql-mesh

🕸️ GraphQL Federation Framework for any API services such as REST, OpenAPI, Swagger, SOAP, gRPC and more...
https://the-guild.dev/graphql/mesh
MIT License
3.27k stars 339 forks source link

graphql-mesh with gRPC and openapi handlers + global transform results in cached variables #6614

Open casuallyhostile opened 7 months ago

casuallyhostile commented 7 months ago

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.


Describe the bug

To Reproduce Steps to reproduce the behavior: Repo to reproduce: https://github.com/casuallyhostile/graphql-mesh-repro-6614

You need to have grpc handler and openapi handler in one .meshrc + use global transform (mode: wrap) e.g.

sources:
  - name: Example
    handler:
      grpc:
        endpoint: localhost:50051
        metaData:
          someKey: 'someValue'
          connection_type: '{context.headers.connection}'
        source: ./proto/service.proto
    transforms:
      - namingConvention:
          fieldNames: camelCase

  - name: StackExchange
    handler:
      openapi:
        source: https://raw.githubusercontent.com/grokify/api-specs/master/stackexchange/stackexchange-api-v2.2_openapi-v3.0.yaml

transforms:
  - namingConvention:
      mode: wrap
      typeNames: pascalCase
      enumValues: upperCase
      fieldNames: camelCase
      fieldArgumentNames: camelCase

Create query with variables e.g.

query Test($genre: Genre) {
  exampleGetMovies(input: {
    movie: {
      genre: $genre
    }
  }) {
    result {
      name
    }
  }
}

send 2 request, whith different variables e.g.

{ "genre": "ACTION" } # Request number one
{ "genre": "DRAMA" } # Request number two

Expected behavior

Second request should return "DRAMA" movies, but it returns "ACTION" movies. If you log request details you will see that second request got the cached values from first request

Screenshot 2024-02-29 at 15 29 05
[0] {
[0]   "movie": {
[0]     "genre": 1
[0]   }
[0] }
[0] called with MetaData: {"somekey":"someValue","connection_type":"keep-alive","user-agent":"grpc-node-js/1.10.1"}
[0] {
[0]   "movie": {
[0]     "genre": 1
[0]   }
[0] }
[0] called with MetaData: {"somekey":"someValue","connection_type":"keep-alive","user-agent":"grpc-node-js/1.10.1"}

Environment:

Additional context

casuallyhostile commented 7 months ago

I have a suspicion that this issue could be related to https://github.com/ardatan/graphql-mesh/issues/6053