graph-node icon indicating copy to clipboard operation
graph-node copied to clipboard

Q: Graph-node subscriptions

Open Jacob273 opened this issue 3 years ago • 3 comments

Q: Is there any way to subscribe (e.g via websocket) for event (eth contract's event) which is handled in subgraph/graph-node?

  1. Let's say we have following event defined in subgraph.yaml under eventhandlers.event: - event: Transfer(indexed address,indexed address,indexed uint256) handler: handleTransfer

  2. Such event ( Transfer(indexed address,indexed address,indexed uint256) ) is also defined in contract's ABI (and so it is published by eth network).

Is there any way to subscribe for it directly via graph-node, so that every transfer which results in saving some data/entity in graph-node and which we may query for will be immediately published? Or does this kind of publishing logic has to be included in the event handler? (or as I understood its subgraph which shall define type Subscription in its schema.graphql, so we may then listen for it through graph-node, yes?)

I would like to not have to make any kind of polling and get real-time data from the graph-node when it does save data/entities.

Jacob273 avatar Jun 09 '22 08:06 Jacob273

Is there any example/doc regarding how we may subscribe through GRAPH-QL-WS? I've managed to connect to graphql-ws for one of the subgraphs but I did not manage to subscribe for anything.

Jacob273 avatar Jun 09 '22 09:06 Jacob273

I'll close it as there's no activity.

Jacob273 avatar Jun 15 '22 23:06 Jacob273

Same here, may be websocket is not implement.

khuepm avatar Sep 21 '22 05:09 khuepm

Hello, is there any documentation for the above one? Cause i would like to use graphql subscriptions to subscribe to entities changes when events are emitted and handlers modify entities, instead of using graphql polling

eldimious avatar Dec 19 '23 15:12 eldimious