Ten named governance frameworks — from quadratic and conviction voting to futarchy — with the tradeoffs of each and how DAOs combine them without deadlocking.
A Subgraph is a custom API built on The Graph protocol that indexes and organizes blockchain data for efficient querying using GraphQL. It defines what data to index and how to structure it for queries.
Think of a subgraph as a custom database schema for blockchain data - you define what to track and how to query it.
The Graph Protocol Overview
How The Graph Works
1. Developer creates subgraph
- Defines schema
- Writes mappings
- Deploys to network
2. Indexers process data
- Run nodes
- Index blockchain
- Serve queries
3. Applications query data
- GraphQL queries
- Instant results
- Pay with GRT tokens
Copy link
Subgraph Components
1. Schema (schema.graphql)
Defines data structure
type Token @entity {
id: ID!
name: String!
symbol: String!
decimals: Int!
totalSupply: BigInt!
}
type Transfer @entity {
id: ID!
token: Token!
from: Account!
to: Account!
value: BigInt!
timestamp: BigInt!
}
type Account @entity {
id: ID!
balance: BigInt!
transfers: [Transfer!]! @derivedFrom(field: "from")
}
# Get all transfers
{
transfers(first: 10, orderBy: timestamp, orderDirection: desc) {
id
from
to
value
timestamp
}
}
# Get account balance
{
account(id: "0x1234...") {
id
balance
transfers(first: 5) {
id
value
timestamp
}
}
}
# Filter and paginate
{
transfers(
where: { value_gt: "1000000000000000000" }
first: 100
skip: 0
orderBy: timestamp
orderDirection: desc
) {
id
from
to
value
}
}
Copy link
Using in Applications
import { createClient } from '@urql/core'
const client = createClient({
url: 'https://api.thegraph.com/subgraphs/name/...'
})
const query = `
query {
transfers(first: 10) {
id
from
to
value
}
}
`
const result = await client.query(query).toPromise()