Skip to main content

6. Compile and Deploy

Finally we will compile and deploy the graph to begin indexing.

Compile

Click Compile code to compile and fix any errors.

Deploy

You can deploy your indexer once you've compiled your contracts.

Deploy

Once deployed you won't be able to edit the handler logic. If you made a mistake or want to make any updates, you can easily fork the graph to create a new one and edit that one.

Once you've clicked deploy, the backfilling process will start and the indexing engine will run your handlers against historical logs.

After indexing catches up to the tip, the status will change to Synced and you'll be able to query your index. This deployment generates a GraphQL playground for testing your queries.

GraphQL Playground

Let's write a simple query to fetch the pairs that most recently had a swap along with the last swap for each pair:

Sample GraphQl Query
query PoolsWithMostRecentSwaps {
pairs(orderBy: "lastSwapTime", orderDirection: "desc") {
items {
id
createdAt
createdTxHash
lastSwapTime
lastSwapTxHash
reserve0
reserve1
token0
token1
swaps(
limit: 1
orderBy: "time"
orderDirection: "desc"
) {
items {
amount1Out
amount1In
amount0Out
amount0In
}
}
}
}
}

Click the run arrow button to execute the query in the playground and you get:

GraphQL Playground

Important

After deployment, contracts are immutable (read-only). If errors are discovered or updates are needed, use our utility to fork your graph and apply necessary changes.

(Optionally) Share Your Graph

Once your Ghost Graph is deployed, you have the option to share it with the Ghost community. Any graphs you share will be accessible to all Ghost users in the Library page.

SharedGraph