How to use @live queries with graph-client?

How to use @live queries with graph-client?


0

I have successfully configured graph-client, and following the documentation, I updated my .graphclientrc.yml including the following:

plugins:
  - pollingLive:
      defaultInterval: 1000

This is the query I am trying to execute, which works just fine without the @live decorator:

query GetOrderById($id: Bytes!, $historyOrder: OrderDirection!) @live {
    orders(where: { id: $id }) {
        id
        requester
        tokenAddress
        initialTokens
        availableTokens
        pricePerToken
        formattedPricePerToken
        requestedETHAmount
        state
        history(orderBy: timestamp, orderDirection: $historyOrder) {
            id
            type
            transactionHash
            timestamp
            state
            fill {
                tokenAmount
            }
        }
    }
}

As soon as I restore the decorator and do graphclient build, the execute function then returns a Repeater, which I can’t find documented anywhere and to which I suppose I would need to subscribe somehow similarly to a RxJS Subject.

import { GetOrderByIdDocument, execute } from "@/graphclient/index"

//...

useEffect(() => {
    execute(GetOrderByIdDocument, { id, historyOrder: "desc" })
        .then((result) => {
            console.log(result) // Repeater object?
        .finally(() => setLoading(false))
}, [id])

I also tried using the subscribe function from the same generated module, but that also returns the same Repeater object.

How can I consume and handle this data? Is there a proper documentation anywhere?


Load 5 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *