# Foundation following list to dune

By [shobon](https://paragraph.com/@shobon) · 2022-03-01

---

1\. run this in dev tool to get the WHERE condition (following list)

    const ADDRESS = '0x...' // replace "0x..." to your address
    fetch(
      'https://hasura2.foundation.app/v1/graphql', {
      'referrer': 'https://foundation.app/',
      'referrerPolicy': 'strict-origin-when-cross-origin',
      'body': JSON.stringify({
          'query': `
              query UserFollowing($publicKey: String!, $currentUserPublicKey: String!, $offset: Int!, $limit: Int!) {
            user: user_by_pk(publicKey: $publicKey) {
              following(where: {isFollowing: {_eq: true}}, offset: $offset, limit: $limit) {
                user: userByFollowedUser {
                  name
                  username
                  publicKey
                  isFollowingUser: follows_aggregate(
                    where: {user: {_eq: $currentUserPublicKey}, isFollowing: {_eq: true}}
                  ) {
                    aggregate {
                      count
                    }
                  }
                }
              }
            }
          }
        `,
        'variables': {
            'publicKey': ADDRESS,
            'currentUserPublicKey': ADDRESS,
            'limit': 42069,
            'offset': 0
        }
      }),
      'method': 'POST',
      'mode': 'cors',
      'credentials': 'omit'
    })
      .then(response => response.json())
      .then(
        ({
          data: {
            user: {
              following = []
            }
          }
        }) => {
          const conditions = following
            .map(({
              user: {
                name,
                username,
                publicKey
              }
            }) => `seller = '${publicKey.replace('0x', '\\x')}' -- ${name} (@${username})`)
            .join("\n" + '  OR ');
          console.log(`(${"\n" + '     '}${conditions}${"\n"})`);
        }
      );
    

![](https://storage.googleapis.com/papyrus_images/567efd81daeca0598248e193f53e8198290df3d6130841f3d451d95ab6293d32.png)

You will get the WHERE condition, copy the output to somewhere.

2\. second query for displaying name instead of address on dune

    const ADDRESS = '0x...' // replace "0x..." to your address
    fetch(
      'https://hasura2.foundation.app/v1/graphql', {
      'referrer': 'https://foundation.app/',
      'referrerPolicy': 'strict-origin-when-cross-origin',
      'body': JSON.stringify({
          'query': `
              query UserFollowing($publicKey: String!, $currentUserPublicKey: String!, $offset: Int!, $limit: Int!) {
            user: user_by_pk(publicKey: $publicKey) {
              following(where: {isFollowing: {_eq: true}}, offset: $offset, limit: $limit) {
                user: userByFollowedUser {
                  name
                  username
                  publicKey
                  isFollowingUser: follows_aggregate(
                    where: {user: {_eq: $currentUserPublicKey}, isFollowing: {_eq: true}}
                  ) {
                    aggregate {
                      count
                    }
                  }
                }
              }
            }
          }
        `,
        'variables': {
            'publicKey': ADDRESS,
            'currentUserPublicKey': ADDRESS,
            'limit': 42069,
            'offset': 0
        }
      }),
      'method': 'POST',
      'mode': 'cors',
      'credentials': 'omit'
    })
      .then(response => response.json())
      .then(
        ({
          data: {
            user: {
              following = []
            }
          }
        }) => {
          const conditions = following
            .map(({
              user: {
                name,
                username,
                publicKey
              }
            }) => `        WHEN seller = '${(publicKey || '').replace('0x', '\\x')}' THEN '${(name || '').replace("'", "’")} (@${username})'`)
            .join("\n");
          console.log(conditions);
        }
      );
    

![](https://storage.googleapis.com/papyrus_images/8a1e53096b06c16f6cad13100d5252b8d578906517618e052603155001ad7d29.png)

3\. fork these queries [https://dune.xyz/queries/337651](https://dune.xyz/queries/337651) [https://dune.xyz/queries/338794](https://dune.xyz/queries/338794) [https://dune.xyz/queries/338811](https://dune.xyz/queries/338811)

[https://dune.xyz/queries/338678](https://dune.xyz/queries/338678) [https://dune.xyz/queries/338730](https://dune.xyz/queries/338730) [https://dune.xyz/queries/338737](https://dune.xyz/queries/338737) [https://dune.xyz/queries/338987](https://dune.xyz/queries/338987) [https://dune.xyz/queries/339019](https://dune.xyz/queries/339019) [https://dune.xyz/queries/339021](https://dune.xyz/queries/339021) [https://dune.xyz/queries/341166](https://dune.xyz/queries/341166) [https://dune.xyz/queries/341230](https://dune.xyz/queries/341230) [https://dune.xyz/queries/341233](https://dune.xyz/queries/341233)

4\. replace “CASE WHEN seller = xxx” and “WHERE seller = xxx” in first 3 queries

5\. replace “WHERE seller = xxx” in remain 9 queries

6\. create your own dashboard and organize it

7\. done ser

might do better SQL next time 🥺

---

*Originally published on [shobon](https://paragraph.com/@shobon/foundation-following-list-to-dune)*
