Subscriptions
Generating the client
# Generate the client
zeus schema.gql ./ --subscriptions graphql-ws
# Add graphql-ws to your project's dependencies
npm install graphql-ws// Create a new Subscription with some authentication headers
const wsChain = Subscription('wss://localhost:4000/graphql', {
get headers() {
return { Authorization: `Bearer ${getToken()}` };
},
});
// Subscribe to new messages
wsChain('subscription')({
message: {
body: true,
},
}).on(({ message }) => {
console.log(message.body);
});Last updated
Was this helpful?