You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 17, 2025. It is now read-only.
Use the `publish` on your graphql-lambda-subscriptions server to publish events to active subscriptions. Payloads must be of type `Record<string, any>` so they can be filtered and stored.
353
+
Use the [`publish()`](docs/interfaces/SubscriptionServer.md#publish) function on your graphql-lambda-subscriptions server to publish events to active subscriptions. Payloads must be of type `Record<string, any>` so they can be filtered and stored.
Use the `complete` on your graphql-lambda-subscriptions server to complete active subscriptions. Payloads are optional and match against filters like events do.
Context values are accessible in all callback and resolver functions (`resolve`, `filter`, `onAfterSubscribe`, `onSubscribe` and `onComplete`).
399
-
400
-
<details>
401
-
402
-
<summary>📖 Default value</summary>
403
-
404
-
Assuming no `context` argument is provided, the default value is an object containing a `connectionInitPayload` attribute.
405
-
406
-
This attribute contains the [(optionally parsed)](#events) payload from `connection_init`.
407
-
408
-
```ts
409
-
exportconst resolver = {
410
-
Subscribe: {
411
-
mySubscription: {
412
-
resolve: (event, args, context) => {
413
-
console.log(context.connectionInitPayload); // payload from connection_init
414
-
},
415
-
},
416
-
},
417
-
};
418
-
```
419
-
420
-
</details>
398
+
[Context](docs/interfaces/ServerArgs.md#context) is provided on the [`ServerArgs`](docs/interfaces/ServerArgs.md) object when creating a server. The values are accessible in all callback and resolver functions (eg. `resolve`, `filter`, `onAfterSubscribe`, `onSubscribe` and `onComplete`).
421
399
422
-
<details>
400
+
Assuming no `context` argument is provided when creating the server, the default value is an object with `connectionInitPayload`, `connectionId` properties and the [`publish()`](docs/interfaces/SubscriptionServer.md#publish) and [`complete()`](docs/interfaces/SubscriptionServer.md#complete) functions. These properties are merged into a provided object or passed into a provided function.
423
401
424
-
<summary>📖 Setting static context value</summary>
402
+
####Setting static context value
425
403
426
404
An object can be provided via the `context` attribute when calling `makeServer`.
If set you can use the `stepFunctionsHandler` and a step function to setup a per connection ping/pong cycle to detect disconnects sooner than the 10 minute idle timeout.
* If set you can use the `stepFunctionsHandler` and a step function to setup a per connection ping/pong cycle to detect disconnects sooner than the 10 minute idle timeout.
0 commit comments