ardatan / graphql-mesh

🕸️ GraphQL Mesh - The Graph of Everything - Federated architecture for any API service
https://the-guild.dev/graphql/mesh
MIT License
3.21k stars 329 forks source link

Error: No `subscribe` function found! Register it using "useEngine" plugin. #6993

Open Jhomalex opened 1 month ago

Jhomalex commented 1 month ago

``Hello!

I have a server with graphql-mesh. Querys and mutations works well, but when I try to call a subscription, the server of graphql-mesh does not work and return me this error:

Internal error occurred during message handling. Please check your implementation. Error: No `subscribe` function found! Register it using "useEngine" plugin.
    at throwEngineFunctionError (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\@envelop+core@5.0.1\node_modules\@envelop\core\cjs\orchestrator.js:7:11)
    at subscribe (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\@envelop+core@5.0.1\node_modules\@envelop\core\cjs\orchestrator.js:15:29)
    at C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\@envelop+core@5.0.1\node_modules\@envelop\core\cjs\orchestrator.js:287:32
    at async Object.onMessage [as handleMessage] (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\graphql-ws@5.16.0_graphql@15.8.0\node_modules\graphql-ws\lib\server.js:199:51)
    at async message (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\graphql-ws@5.16.0_graphql@15.8.0\node_modules\graphql-ws\lib\use\uWebSockets.js:116:17)

I could see that, when I try to subscribe to the server of graphql-mesh, it dindn't send the "request" to my source server.

I'm using this versions of packages: "@graphql-mesh/cli": "0.90.5", "@graphql-mesh/graphql": "0.98.4", "@graphql-mesh/runtime": "0.99.5", "@graphql-mesh/store": "0.98.4", "@graphql-mesh/utils": "0.98.4", "@graphql-tools/utils": "10.2.0", "graphql": "16.8.1"

and this is a part of my meshrc.yaml file:

serve:
  hostname: 0.0.0.0
  port: 5000
  playground: true
  browser: false
sources:
  - name: chats-service
    handler:
      graphql:
        endpoint: ${CHATS_ENDPOINT}
        subscriptionsEndpoint: ${CHATS_SUBSCRIPTIONS_ENDPOINT}
        subscriptionsProtocol: WS
        operationHeaders:
          Authorization: "{context.headers['authorization']}"
          Language: "{context.headers['language']}"
          "connectionstatus": "{context.headers['connectionstatus']}"
          "connectionid": "{context.headers['connectionid']}"
        connectionParams:
          Authorization: "{context.connectionParams['authorization']}"
          Language: "{context.connectionParams['language']}"
          "connectionstatus": "{context.connectionParams['connectionstatus']}"
          "connectionid": "{context.connectionParams['connectionid']}"
      multipart: true
ardatan commented 1 month ago

Could you create a reproduction on CodeSandbox or StackBlitz? Thanks!

Jhomalex commented 1 month ago

This is a Sandbox that I made with a similar setup. The problem is that I can't request from Apollo Studio.

Curiously, I tried to test only the source that has WS connections (I removed the rest of the sources), and It works, but, when I added one of the rest, It fail another time.

Codesandbox