-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Good afternoon to you, The Guild,
Thank you for all the previous engagements with you. I have been absent from the slack channel for a while, partly due to the fact that slack has been blocked where I am and I lost all access across my work devices.
I came here today because I was looking at Hive Gateway, which I believe is node based, as a replacement for the Apollo Router due to subscription support.
I was having an issue similar to this existing issue: Unable to specify subscriptions HTTP method when using proxy mode #1259
I have a Spring Boot GraphQL Service and the SSE Subscription portion is documented here..
I'll summarize here what the documentation says:
Server-Sent Events
With this transport, clients must send HTTP POST requests to the endpoint with "application/json" as content type and GraphQL request details included as JSON in the request body; the only difference with the vanilla HTTP variant is that the client must send "text/event-stream" as the "Accept" request header. The response will be sent as one or more Server-Sent Event(s).This is also defined in the proposed GraphQL over HTTP specification. Spring for GraphQL only implements the "Distinct connections mode", so applications must consider scalability concerns and whether adopting HTTP/2 as the underlying transport would help.
With that in mind, I tried to get this working. By default, Hive Gateway will send the request to the subgraph with a GET. However, as you can see from the documentation a POST
is requested with the correct Accept
header.
Similar to the above issue I mentioned, I want to switch the subgraph call to a POST instead. Is this possible?
I also should mention that the Hive Gateway will run in a federated schema style. Here is my configuration right now.
import { defineConfig } from '@graphql-hive/gateway'
export const gatewayConfig = defineConfig({
graphqlEndpoint: '/graphql',
supergraph: './scripts/graphql/supergraph.schema.graphqls',
healthCheckEndpoint: '/healthcheck',
pollingInterval: 10_000,
propagateHeaders: {
fromClientToSubgraphs({request, subgraphName}) {
console.log(subgraphName)
return {
authorization: request.headers.get('authorization')
}
},
fromSubgraphsToClient({ response, subgraphName }) {
return {
'x-subgraphname': subgraphName
}
}
},
disableWebsockets: true
})
With the above configuration I get this in the console.
[2025-08-07T15:38:20.568Z] ERROR Error: No response returned
at file:///private/var/folders/hf/frlxhnl979v1f3cdl7qyqf_h0000gp/T/graphql-hive__gateway_9ef70cae46fe3190153273fd7d3e1e5c3c71703ea2def620f6b77a8466138cd0_node_modules/.chunk/index-DUmrqrHb.mjs:1124:42
at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
path: [ 'greetings' ],
locations: undefined,
extensions: {
request: {
method: 'GET',
url: 'http://localhost:8087/graphql?query=subscription%7Bgreetings%7D'
},
response: { status: 405, statusText: 'Method Not Allowed', body: '' },
code: 'DOWNSTREAM_SERVICE_ERROR',
serviceName: 'graphql-subscription-poc'
}
}
Currently my schema looks like this and is dead simple. I can also provide the supergraph.schema.graphqls
file that is generated with rover if necessary.
type Query {
dummyFieldNecessaryForSpringBoot: String
}
type Mutation {
sendGreeting(greeting: String): String
}
type Subscription {
greetings: String
}
Things that I have tried
I have tried these things with varying results:
Added transportEntries
to the gateway config file above
transportEntries: {
'graphql-subscription-poc': {
options: {
subscriptions: {
// http is the default from what I saw
// kind: 'http',
method: 'POST'
}
}
}
},
Infinite loop
I looked at the logs after adding the above and this happens:
[2025-08-07t15:45:46.005z] debug �[35m parsing request to extract graphql parameters �[0m
[2025-08-07t15:45:46.006z] debug �[35m parsing request to extract graphql parameters �[0m
[2025-08-07t15:45:46.011z] debug �[35m processing graphql parameters �[0m
[2025-08-07T15:45:46.017Z] DEBUG [�[1mrequestId=b3643c02-98a5-4f6e-8f26-d9c56ec59bcf, subgraph=graphql-subscription-poc�[0m] �[35m Initializing executor �[0m
[2025-08-07T15:45:46.019Z] DEBUG [�[1msubgraph=graphql-subscription-poc�[0m] �[35m Loading transport "http" �[0m
[2025-08-07T15:45:46.022Z] DEBUG [�[1mrequestId=b3643c02-98a5-4f6e-8f26-d9c56ec59bcf, subgraph=graphql-subscription-poc, subgraphExecuteId=31968131-4229-4e17-b459-ffbe1ef4c0c5, subgraph-execute-start�[0m] �[35m { query: 'subscription{greetings}' } �[0m
[2025-08-07T15:45:46.022Z] DEBUG [�[1msubgraph=graphql-subscription-poc�[0m] �[35m Loading transport "http" �[0m
[2025-08-07T15:45:46.022Z] DEBUG [�[1msubgraph=graphql-subscription-poc�[0m] �[35m Loading transport "http" �[0m
[2025-08-07T15:45:46.023Z] DEBUG [�[1msubgraph=graphql-subscription-poc�[0m] �[35m Loading transport "http" �[0m
[2025-08-07T15:45:46.023Z] DEBUG [�[1msubgraph=graphql-subscription-poc�[0m] �[35m Loading transport "http" �[0m
[2025-08-07T15:45:46.023Z] DEBUG [�[1msubgraph=graphql-subscription-poc�[0m] �[35m Loading transport "http" �[0m
[2025-08-07T15:45:46.023Z] DEBUG [�[1msubgraph=graphql-subscription-poc�[0m] �[35m Loading transport "http" �[0m
[2025-08-07T15:45:46.023Z] DEBUG [�[1msubgraph=graphql-subscription-poc�[0m] �[35m Loading transport "http" �[0m
[2025-08-07T15:45:46.023Z] DEBUG [�[1msubgraph=graphql-subscription-poc�[0m] �[35m Loading transport "http" �[0m
Eventually memory runs out and this is printed.
<--- Last few GCs --->
[8232:0x130008000] 151987 ms: Mark-Compact 4058.3 (4104.5) -> 4050.8 (4104.7) MB, pooled: 0 MB, 1575.46 / 0.00 ms (average mu = 0.279, current mu = 0.221) task; scavenge might not succeed
[8232:0x130008000] 153601 ms: Mark-Compact 4057.4 (4105.7) -> 4051.2 (4104.0) MB, pooled: 2 MB, 1575.21 / 0.00 ms (average mu = 0.171, current mu = 0.024) task; scavenge might not succeed
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Other transportEntries
attempts
I attempted several other things with the transportEntries
parameter but I didn't get beyond the infinite loop mentioned above. I tried these configs:
transportEntries: {
'graphql-subscription-poc': {
options: {
subscriptions: {
fetchOptions: {
method: 'POST'
}
},
// trying to comply with Spring Boot GraphQL
operationHeaders: {
'Content-Type': 'application/json',
'Accept': 'text/event-stream'
}
}
}
},
transportEntries: {
'*.http': {
options: {
subscriptions: {
fetchOptions: {
method: 'POST'
}
},
operationHeaders: {
'Content-Type': 'application/json',
'Accept': 'text/event-stream'
}
}
}
},
Any help is appreciated. If there is an example repo or a page with configuration options I can reference please let me know.
I'm currently trying to dig into the graphql mesh code repository to further investigate some of the options. I don't know why the code recurses and keeps attempting to load the http transport.