graphql-mesh
graphql-mesh copied to clipboard
RPC Method Named 'Close' Conflicts with Client Connection Close Operation in GraphQL Mesh gRPC Handling
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
When using GraphQL Mesh to wrap a gRPC service, a naming conflict arises if the service includes an RPC method named Close. The conflict occurs because the client.close() operation, intended to close the client connection, is mistakenly treated as an invocation of the RPC Close method. This issue specifically manifests during the mesh build
process, leading to unintended behavior and errors.
Error Scenario: The error occurs in the context of dynamically subscribing to a destroy event and attempting to close the gRPC client connection:
const subId = this.pubsub.subscribe('destroy', () => {
client.close(); // Expected to close the connection, not invoke an RPC method
});
However, because an RPC method named Close exists, calling client.close() attempts to invoke this RPC method instead of closing the client connection, leading to errors and unexpected behavior.
To Reproduce Steps to reproduce the behavior:
- Define a gRPC service with an RPC method named Close.
- Use GraphQL Mesh to wrap this gRPC service.
- Run the mesh build process.
- Observe the error during the build process, specifically when the destroy event triggers an attempt to close the client connection.
An example RPC:
service MyService {
rpc Close (CloseRequest) returns (CloseResponse) {}
}
Expected behavior
The client.close() operation should close the gRPC client connection without invoking any RPC method, regardless of the existence of an RPC method named Close.
Environment:
- OS: Mac
- "@graphql-mesh/cli": "^0.88.6",
- "@graphql-mesh/grpc": "^0.97.3",
- "@graphql-mesh/openapi": "^0.97.4",
- NodeJS: 18
Additional context
Potential Solution: Explore modifications to the GraphQL Mesh gRPC handling code to distinguish between the connection closing operation and RPC method invocations, potentially by aliasing or wrapping one of the operations.
Seeking guidance on best practices to resolve this naming conflict, including any recommended changes to the gRPC service definition or adjustments to GraphQL Mesh configuration to ensure the correct operation of client.close().