@alxia/graphql 0.11.1 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/guide/yoga.md +18 -0
- package/docs/troubleshooting.md +22 -0
- package/package.json +3 -3
package/docs/guide/yoga.md
CHANGED
|
@@ -207,6 +207,24 @@ describes.
|
|
|
207
207
|
are sent as they are produced. A `compressible` that lets event streams in
|
|
208
208
|
still sends each result at once: a streamed body is flushed as it comes.
|
|
209
209
|
|
|
210
|
+
### Keep an idle subscription open
|
|
211
|
+
|
|
212
|
+
Yoga sends a keep-alive ping on an open stream every 12 seconds. `Bun.serve`
|
|
213
|
+
closes a connection that has been idle for `idleTimeout` seconds, 10 by
|
|
214
|
+
default, so on a real server a subscription that has nothing to send is reset
|
|
215
|
+
at about 8 to 10 seconds, before the first ping. `app.request(…)` in a spec
|
|
216
|
+
goes through no socket and never shows it. Give `listen` an `idleTimeout`
|
|
217
|
+
above the ping interval:
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
app.listen({ port: 3000, idleTimeout: 30 }); // seconds, longer than the 12 s ping
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Calling `server.timeout(request, 0)` from a resolver does not lift it for the
|
|
224
|
+
stream. Behind a proxy or load balancer, its own read timeout must be longer
|
|
225
|
+
than 12 seconds too. See
|
|
226
|
+
[the troubleshooting entry](../troubleshooting.md#an-idle-subscription-over-sse-is-reset-after-about-10-seconds).
|
|
227
|
+
|
|
210
228
|
## CORS
|
|
211
229
|
|
|
212
230
|
Yoga's own CORS is off (`cors: false`): the endpoint is a route of the app,
|
package/docs/troubleshooting.md
CHANGED
|
@@ -47,6 +47,7 @@ symptom.
|
|
|
47
47
|
- [The logger, CORS or secure headers miss the endpoint](#the-logger-cors-or-secure-headers-miss-the-endpoint)
|
|
48
48
|
- [An anonymous request to a missing path is a 401](#an-anonymous-request-to-a-missing-path-is-a-401)
|
|
49
49
|
- [A WebSocket client cannot connect: `Expected 101 status code`](#a-websocket-client-cannot-connect-expected-101-status-code)
|
|
50
|
+
- [An idle subscription over SSE is reset after about 10 seconds](#an-idle-subscription-over-sse-is-reset-after-about-10-seconds)
|
|
50
51
|
- [The IDE page is blank](#the-ide-page-is-blank)
|
|
51
52
|
- [GraphiQL is served in production](#graphiql-is-served-in-production)
|
|
52
53
|
- [GraphiQL does not open in development, or in a test](#graphiql-does-not-open-in-development-or-in-a-test)
|
|
@@ -679,6 +680,27 @@ SSE:
|
|
|
679
680
|
graphql(app, { schema, graphiql: { subscriptionsProtocol: 'SSE' } });
|
|
680
681
|
```
|
|
681
682
|
|
|
683
|
+
### An idle subscription over SSE is reset after about 10 seconds
|
|
684
|
+
|
|
685
|
+
**When:** a subscription over server-sent events that has nothing to send
|
|
686
|
+
for a few seconds, on a real server: the client sees the connection reset at
|
|
687
|
+
8 to 10 seconds, before any event. A spec using `app.request` never shows it.
|
|
688
|
+
|
|
689
|
+
**Why:** Yoga pings an open stream every 12 seconds, but `Bun.serve` closes a
|
|
690
|
+
connection idle for `idleTimeout` seconds, 10 by default, before the first
|
|
691
|
+
ping. `server.timeout(request, 0)` called from a resolver does not change it
|
|
692
|
+
for the stream.
|
|
693
|
+
|
|
694
|
+
**Fix:** set `idleTimeout` above the ping interval in `listen`'s options:
|
|
695
|
+
|
|
696
|
+
```ts
|
|
697
|
+
app.listen({ port: 3000, idleTimeout: 30 });
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
The same holds behind a proxy or load balancer: its read timeout must be
|
|
701
|
+
longer than the ping. For a React Router app, see
|
|
702
|
+
[Subscriptions for a BFF](../../react-router/docs/guide/subscriptions.md#keep-the-stream-alive).
|
|
703
|
+
|
|
682
704
|
### The IDE page is blank
|
|
683
705
|
|
|
684
706
|
**When:** GraphiQL or Apollo Sandbox loads an empty page, and the browser
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alxia/graphql",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "GraphQL for alxia with GraphQL Yoga: its plugins, subscriptions over SSE or WebSocket (graphql-ws) and GraphiQL, behind the app's hooks, its resolvers reading the app's typed context",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
]
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@alxia/core": "^0.17.
|
|
50
|
+
"@alxia/core": "^0.17.1",
|
|
51
51
|
"@alxia/logger": "^0.6.9",
|
|
52
52
|
"@alxia/telemetry": "^0.7.7",
|
|
53
53
|
"@envelop/depth-limit": "^7.2.1",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"graphql-yoga": "^5.16.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@alxia/core": "^0.17.
|
|
64
|
+
"@alxia/core": "^0.17.1",
|
|
65
65
|
"graphql": "^16.11.0 || ^17.0.0",
|
|
66
66
|
"graphql-ws": "^6.1.0",
|
|
67
67
|
"graphql-yoga": "^5.16.0",
|