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

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

Open
Jhomalex opened this issue May 20, 2024 · 4 comments
Open

Comments

@Jhomalex
Copy link

``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\@[email protected]\node_modules\@envelop\core\cjs\orchestrator.js:7:11)
    at subscribe (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\@[email protected]\node_modules\@envelop\core\cjs\orchestrator.js:15:29)
    at C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\@[email protected]\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\[email protected][email protected]\node_modules\graphql-ws\lib\server.js:199:51)
    at async message (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\[email protected][email protected]\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
Copy link
Owner

ardatan commented May 20, 2024

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

@Jhomalex
Copy link
Author

Jhomalex commented May 20, 2024

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

@ardatan
Copy link
Owner

ardatan commented Nov 6, 2024

Could you test it with the latest version?

@Jhomalex
Copy link
Author

Jhomalex commented Nov 7, 2024

Hello!
I tested it now and I received another error with graphq-ws:

Internal error occurred during message handling. Please check your implementation. GraphQLError
    at createGraphQLError (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\@[email protected][email protected]\node_modules\@graphql-tools\utils\cjs\errors.js:31:12)
    at createGraphQLError (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\@[email protected][email protected]\node_modules\@graphql-tools\utils\cjs\errors.js:26:33)
    at wrapError (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\@[email protected][email protected]\node_modules\@graphql-tools\executor\cjs\execution\execute.js:889:43)
    at C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\@[email protected][email protected]\node_modules\@graphql-tools\executor\cjs\execution\execute.js:885:15
    at C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\@[email protected][email protected]\node_modules\@graphql-tools\utils\cjs\mapAsyncIterator.js:64:43
    at new Promise (<anonymous>)
    at asyncMapValue (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\@[email protected][email protected]\node_modules\@graphql-tools\utils\cjs\mapAsyncIterator.js:64:12)
    at mapReject (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\@[email protected][email protected]\node_modules\@graphql-tools\utils\cjs\mapAsyncIterator.js:39:32)
    at async Object.next (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\@[email protected][email protected]\node_modules\@graphql-tools\executor\cjs\execution\flattenAsyncIterable.js:38:43)
    at async onMessage (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\[email protected][email protected]\node_modules\graphql-ws\lib\server.js:216:156) {
  path: undefined,
  locations: undefined,
  extensions: [Object: null prototype] {},
  message: undefined
}
C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\[email protected][email protected]\node_modules\graphql-ws\lib\utils.js:52
    return reason.length < 124 ? reason : whenTooLong;
                  ^

TypeError: Cannot read properties of undefined (reading 'length')
    at limitCloseReason (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\[email protected][email protected]\node_modules\graphql-ws\lib\utils.js:52:19)
    at WebSocket.<anonymous> (C:\Users\jhoma\www\kawchi\kawchi-mesh-service\node_modules\.pnpm\[email protected][email protected]\node_modules\graphql-ws\lib\use\ws.js:90:56)

I changed my .meshrc.yaml file a little bit:

serve:
  hostname: 0.0.0.0
  port: 5000
  playground: true
  browser: false

  sources:
   - name: kawchi-chats-service
      handler:
        graphql:
          endpoint: ${CHATS_ENDPOINT}
          subscriptionsEndpoint: ${CHATS_SUBSCRIPTIONS_ENDPOINT}
          operationHeaders:
            Authorization: "{context.headers['authorization']}"
            Language: "{context.headers['language']}"
            connectionstatus: "{context.headers['connectionstatus']}"
            connectionid: "{context.headers['connectionid']}"
            "client-origin": "{context.headers['origin']}"
            "client-user-agent": "{context.headers['user-agent']}"
            "team-id-signed": "{context.headers['team-id-signed']}"
            "client-host": "{context.headers['host']}"
          connectionParams:
            Authorization: "{context.connectionParams['authorization']}"
            Language: "{context.connectionParams['language']}"
            connectionstatus: "{context.connectionParams['connectionstatus']}"
            connectionid: "{context.connectionParams['connectionid']}"
        multipart: true

I have updated all dependencies to these versions:

"dependencies": {
    "@graphql-mesh/cli": "0.97",
    "@graphql-mesh/graphql": "0.102.14",
    "@graphql-mesh/runtime": "0.104.0",
    "@graphql-mesh/store": "0.102.11",
    "@graphql-mesh/utils": "0.102.11",
    "@graphql-tools/utils": "10.5.5",
    "graphql": "16.8.1",
    "graphql-ws": "^5.16.0"
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants