Guides

Following

Fetch all profiles followed by the target profile.

Request

  • for: profileId (required)
    • The identifier of the profile for which to fetch followed profiles
  • limit: number (optional)
    • The maximum number of profiles to fetch
  • cursor: number (optional)
    • The number of profiles to skip before fetching the first profile

Invocation

const result = await lensClient.profile.following({
  for: "PROFILE_ID",
});
query Following {
  following(request: { for: "PROFILE_ID" }) {
    items {
      ...Profile
    }
    pageInfo {
      ...PaginatedResultInfo
    }
  }
}

Response

A paginated result is returned where the items is an array of Profile.

You will see the paging result behaviour repeated a lot in the API, this is to allow you to fetch a certain amount and then page it for the most optimal request speed. Every time something is wrapped in a paging result you will always get returned a pageInfo which holds the cursors for the previous and next alongside the total count which exists in the database. These cursors are just pointers for the server to get to the next result and do not need to be understood by your client or server. If you ever want to then page to the next result you can pass these previous and next cursor in the request cursor property.

{
  "items": [
    {
      // profile
    }
    // list of profiles
  ],
  "pageInfo": {
    // ...PaginatedResultInfo
  }
}

Full LensClient Example

// your LensClient does not need to be authenticated

const result = await lensClient.profile.following({
  for: "PROFILE_ID",
});

console.log(
  `Following:`,
  result.items.map((p) => p.handle)
);

Full GraphQL API Example

πŸ“˜

Following: GraphQL API Full Example