Open klys-equinix opened 5 days ago
Could you give more details about your subgraphs? Do they use graphql-ws protocol? Or maybe they use the legacy subscriptions-transport-ws?
There is only one subgraph serving subscriptions. It is based on graphql-ws protocol
https://docs.spring.io/spring-graphql/reference/transports.html#server.transports.websocket
But it seems like the gateway is not even trying to call it
Have you tried to make the HTTP request with curl or some other http client?
I tried making a request with Postman GraphQL client. There is says that gateway responded with incorrect response code 200 instead of 101
Here are the logs from this request
{ resource: { attributes: { 'service.name': 'Gateway', 'telemetry.sdk.language': 'nodejs', 'telemetry.sdk.name': 'opentelemetry', 'telemetry.sdk.version': '1.25.1', 'process.pid': 6, 'process.executable.name': 'node', 'process.executable.path': '/usr/local/bin/node', 'process.command_args': [ '/usr/local/bin/node', '/serve/bin.mjs', 'supergraph' ], 'process.runtime.version': '22.8.0', 'process.runtime.name': 'nodejs', 'process.runtime.description': 'Node.js', 'process.command': '/serve/bin.mjs', 'process.owner': 'node', 'host.name': 'hive-gateway-external-7664cc5d55-89g5m', 'host.arch': 'amd64' } }, instrumentationScope: { name: 'gateway', version: undefined, schemaUrl: undefined }, traceId: '4fce12dacd20a8c23d04f77f0cdddbf9', parentId: undefined, traceState: undefined, name: 'GET /gateway/graphql', id: 'c16e61a8e3b4aaaf', kind: 1, timestamp: 1726157965615000, duration: 732.977, attributes: { 'http.method': 'GET', 'http.url': 'http://localhost/gateway/graphql', 'http.route': '/gateway/graphql', 'http.scheme': 'http:', 'net.host.name': 'localhost', 'http.host': 'localhost', 'http.client_ip': '10.249.0.4', 'http.user_agent': 'PostmanClient/undefined (AppId=6217ee3f-4ef9-4f3d-b10a-c0582107b1ea)', 'http.status_code': 200 }, status: { code: 1, message: undefined }, events: [], links: [] }
Can you give me an example of correct curl for querying subscription on gateway?
curl 'http://localhost:4000/graphql' \
-H 'accept: text/event-stream' \
-H 'content-type: application/json' \
--data-raw '{"query":"subscription OnProductPriceChanged { productPriceChanged { name price reviews { score } } }","operationName":"OnProductPriceChanged"}'
You can initiate an SSE connection as in here with curl.
Regarding the error in the screenshots you shared above; In there, you are trying to connect the gateway via WebSockets not SSE. We only support the actively developed graphql-ws only not deprecated subscriptions-transport-ws . I am not sure which one Postman uses there.
Hi, I tried forming the request like in the curl you described. This resulted in error:
event: next
data: {"errors":[{"message":"Cannot find package '@graphql-mesh/transport-ws' imported from /node_modules/.chunk/createGatewayRuntime-DfdVdZl2.mjs","locations":[{"line":1,"column":20}],"path":["inventoryEvents"]}]}
event: complete
data:
And in the logs:
[2024-09-13T09:21:43.876Z] DEBUG vdc-inventory-service - 430ed7d622f261c84c120254f2868472 subgraph-execute {
query: 'subscription test2{inventoryEvents{__typename ...on CabinetStatusChangedEvent{eventId}}}',
variables: {}
}
[2024-09-13T09:21:43.876Z] DEBUG Loading transport "ws" for subgraph vdc-inventory-service
[2024-09-13T09:21:43.877Z] HOOKS Trying default resolve for "@graphql-mesh/transport-ws"
[2024-09-13T09:21:43.879Z] DEBUG Processing GraphQL Parameters done.
[2024-09-13T09:21:43.878Z] HOOKS Trying default resolve for "@graphql-mesh/transport-ws" failed; trying alternatives
[2024-09-13T09:21:43.878Z] HOOKS Trying "@graphql-mesh/transport-ws.ts"
This likely means two things:
Issue workflow progress
Progress of the issue based on the Contributor Workflow
Describe the bug
Graphql subscriptions do not work. If i try to run the subscription through GraphiQL, the response is 404
The OpenTelemetry logs are as follows:
gateway.config.ts: | import {defineConfig, type WSTransportOptions, createStdoutExporter} from '@graphql-hive/gateway'