Genql v3 does not expose a
subscripton
method anymore. You can use
generateSubscriptionOp
to generate a variables
and query
variables to be used with a third party client like graphql-ws
.Example with graphql-ws
Use the
generateSubscriptionOp
to generate the payload to pass to graphql-ws
typescriptimport { generateSubscriptionOp } from "./generated"; import { createClient as createWsClient } from "graphql-ws"; const client = createWsClient({ url: "ws://hey.there:4000/graphql", }); let { query, variables } = generateSubscriptionOp({ onCommentAdded: { __args: { filter: "ciao" }, text: true, date: true, anotherField: jtrue, }, }); client.subscribe( { query, variables }, { next: (data) => console.log(data), error: console.error, complete: () => console.log('finished'), } );