---
title: Following Query
description: Query following relationships in the social graph
url: https://docs.intuition.systems/docs/v1/graphql-api/queries/accounts/following
markdown_url: https://docs.intuition.systems/docs/v1/graphql-api/queries/accounts/following.md
version: V1
llms_index: https://docs.intuition.systems/docs/v1/llms.txt
---

Query the social graph to find who an account follows and who follows them.

## Following Query - Query Structure

```graphql
query GetFollowing(
  $account_id: String!
  $limit: Int
  $offset: Int
) {
  following(
    where: { follower_id: { _eq: $account_id } }
    limit: $limit
    offset: $offset
  ) {
    id
    label
    image
  }
  following_aggregate(where: { follower_id: { _eq: $account_id } }) {
    aggregate {
      count
    }
  }
}
```

## Variables

```json
{
  "account_id": "0x88D0aF73508452c1a453356b3Fac26525aEc23A2",
  "limit": 20,
  "offset": 0
}
```

## Response Fields

| Field | Type | Description |
|-------|------|-------------|
| `id` | `String` | Account address |
| `label` | `String` | Human-readable name |
| `image` | `String` | Profile image URL |

## Expected Response

```json
{
  "data": {
    "following": [
      {
        "id": "0x123...",
        "follower": {
          "label": "vitalik.eth",
          "image": "ipfs://Qm..."
        },
        "following": {
          "label": "alice.eth",
          "image": "ipfs://Qm..."
        }
      }
    ],
    "following_aggregate": {
      "aggregate": {
        "count": 150
      }
    }
  }
}
```

## Interactive Example

    id: 'who-follows',
    title: 'Who Account Follows',
    query: `query GetFollowing($account_id: String!, $limit: Int!) {
  following(
    where: { follower_id: { _eq: $account_id } }
    limit: $limit
  ) {
    id
    label
    image

  following_aggregate(where: { follower_id: { _eq: $account_id } }) {
    aggregate {
      count

}`,
    variables: {
      account_id: '0x88D0aF73508452c1a453356b3Fac26525aEc23A2',
      limit: 10

  },

    id: 'followers',
    title: 'Account Followers',
    query: `query GetFollowers($account_id: String!, $limit: Int!) {
  following(
    where: { following_id: { _eq: $account_id } }
    limit: $limit
  ) {
    id
    label
    image

  following_aggregate(where: { following_id: { _eq: $account_id } }) {
    aggregate {
      count

}`,
    variables: {
      account_id: '0x88D0aF73508452c1a453356b3Fac26525aEc23A2',
      limit: 10

  },

    id: 'mutual-follows',
    title: 'Check Mutual Follow',
    query: `query CheckMutualFollow($account_a: String!, $account_b: String!) {
  a_follows_b: following(where: {
    follower_id: { _eq: $account_a }
    following_id: { _eq: $account_b }
  }) {
    id

  b_follows_a: following(where: {
    follower_id: { _eq: $account_b }
    following_id: { _eq: $account_a }
  }) {
    id

}`,
    variables: {
      account_a: '0x88D0aF73508452c1a453356b3Fac26525aEc23A2',
      account_b: '0xabc...'

];

## Use Cases

### Following List

Get list of accounts a user follows:

```typescript
async function getFollowing(accountId: string, options: {
  limit?: number
  offset?: number
} = {}) {
  const query = `
    query GetFollowing($account_id: String!, $limit: Int!, $offset: Int!) {
      following(
        where: { follower_id: { _eq: $account_id } }
        limit: $limit
        offset: $offset
      ) {
        id
        label
        image
      }
      following_aggregate(where: { follower_id: { _eq: $account_id } }) {
        aggregate {
          count
        }
      }
    }
  `

  const data = await client.request(query, {
    account_id: accountId,
    limit: options.limit || 20,
    offset: options.offset || 0
  })

  return {
    accounts: data.following,
    total: data.following_aggregate.aggregate.count
  }
}
```

### Followers List

Get accounts that follow a user:

```typescript
async function getFollowers(accountId: string) {
  const query = `
    query GetFollowers($account_id: String!) {
      following(
        where: { following_id: { _eq: $account_id } }
      ) {
        id
        label
        image
      }
      following_aggregate(where: { following_id: { _eq: $account_id } }) {
        aggregate {
          count
        }
      }
    }
  `

  const data = await client.request(query, { account_id: accountId })

  return {
    followers: data.following,
    count: data.following_aggregate.aggregate.count
  }
}
```

### Check if Following

Check if one account follows another:

```typescript
async function isFollowing(
  followerId: string,
  followingId: string
): Promise<boolean> {
  const query = `
    query CheckFollowing($follower: String!, $following: String!) {
      following(where: {
        follower_id: { _eq: $follower }
        following_id: { _eq: $following }
      }) {
        id
      }
    }
  `

  const data = await client.request(query, {
    follower: followerId,
    following: followingId
  })

  return data.following.length > 0
}
```

### React Following Component

```tsx
function FollowingList({ accountId }: { accountId: string }) {
  const [tab, setTab] = useState<'following' | 'followers'>('following')

  const { data, loading } = useQuery(
    tab === 'following' ? GET_FOLLOWING : GET_FOLLOWERS,
    { variables: { account_id: accountId } }
  )

  const accounts = data?.following?.map(f =>
    tab === 'following' ? f.following : f.follower
  ) || []

  const count = data?.following_aggregate?.aggregate?.count || 0

  return (
    <div>
      <div className="tabs">
        <button
          onClick={() => setTab('following')}
          className={tab === 'following' ? 'active' : ''}
        >
          Following
        </button>
        <button
          onClick={() => setTab('followers')}
          className={tab === 'followers' ? 'active' : ''}
        >
          Followers
        </button>
      </div>

      <p>{count} {tab}</p>

      {loading ? (
        <Spinner />
      ) : (
        <ul>
          {accounts.map(account => (
            <li key={account.id}>
              <AccountCard account={account} />
            </li>
          ))}
        </ul>
      )}
    </div>
  )
}
```

## How Following Works

Following relationships are created through:
1. Creating "Follow" triples (subject follows object)
2. The indexer extracts these into the `following` table

## Best Practices

1. **Paginate lists** - Following lists can be large
2. **Cache counts** - Aggregate counts are relatively stable
3. **Show mutual follows** - Indicate when users follow each other
4. **Use for feeds** - Power social features with following data

## Related

- [Signals from Following](https://docs.intuition.systems/docs/v1/graphql-api/queries/signals/signals-from-following) - Activity from followed accounts
- [Positions from Following](https://docs.intuition.systems/docs/v1/graphql-api/queries/accounts/positions-from-following) - Positions from followed accounts
- [Social Graph Example](https://docs.intuition.systems/docs/v1/graphql-api/examples/social-graph) - Building social features
