Skip to content

Instantly share code, notes, and snippets.

@jjgonecrypto
Last active December 1, 2019 23:33
Show Gist options
  • Save jjgonecrypto/59fbb8bb1448c95160149c4b6aa8c27b to your computer and use it in GitHub Desktop.
Save jjgonecrypto/59fbb8bb1448c95160149c4b6aa8c27b to your computer and use it in GitHub Desktop.
Synthetix subgraph websocket
'use strict';
const WebSocket = require('ws');
const client = new WebSocket('wss://api.thegraph.com/subgraphs/name/synthetixio-team/synthetix-exchanges', [
'graphql-ws',
]);
client.on('open', () => {
console.log('open');
client.send(JSON.stringify({ id: 123, type: 'GQL_CONNECTION_INIT' }));
// client.send(' subscription { synthExchanges { id } }');
});
client.on('message', data => console.log('message', data));
client.on('close', () => console.log('close'));
client.on('error', err => {
console.log('error', err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment