typed-graphql-subscriptions (v0.0.1) is a TypeScript library that provides a type-safe wrapper around the graphql-subscriptions PubSub engine. It enforces channel names and payload types via generics, reducing runtime errors in GraphQL subscription publishing. The library is maintained by ContraWork and ships with TypeScript definitions. Key differentiators: strict type safety over plain graphql-subscriptions, support for composite channel names like chatMessageReceived:42, and compatibility with any PubSubEngine implementation.
npm install typed-graphql-subscriptionsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Install package, define channel types, instantiate TypedPubSub, subscribe and publish with type safety.
Ensure Channels type maps each channel name to a tuple of arguments precisely.
Use a PubSub instance that conforms to PubSubEngine interface, e.g., from graphql-subscriptions or graphql-amqp-subscriptions.
Ensure the payload matches the tuple type defined in the Channels mapping.
Use correct import: import { TypedPubSub } from 'typed-graphql-subscriptions'