Follow and Unfollow
This guide explains how to follow and unfollow an Account on Lens.
Lens Account can follow other Lens accounts on the Global Graph or on Custom Graphs.
Follow operations are regulated by Follow Rules set on the target Account and by the Graph Rule of the Graph where the follow relationship is established. More information on this will be provided in due course.
Follow an Account
To follow an account, you need to:
Check Follow permissions
Submit a Follow request
All steps in this section assumes are authenticated as Account Owner or Account Manager.
First, inspect the account's operations.canFollow field to determine if you can follow the account.
- GraphQL
- TypeScript
Account
fragment Account on Account { # ...
operations { # defaults to the Global Graph canFollow isFollowedByMe
# or use aliases for a specific Graph # canFollowOnMyGraph: canFollow(request: { graph: "0x123…" }) # isFollowedByMeOnMyGraph: isFollowedByMe(request: { graph: "0x123…" })
# ... }}
The value of which can be:
YES - Your Account meets the follow criteria the target Account Owner has set.
- NO - You cannot follow the target Account. This could be for 2 reasons:
Your Account already follows the target Account, in this case the operation.isFollowedByMe field will be true.
Your Account does not meet the follow criteria the target Account Owner has set.
UNKNWOWN - Indicates the Account's follow permissions are not known. This could be due to the use of a Custom Follow Rule (more on this later).
Then, if your follow request is allowed, you can proceed with submitting the request.
- GraphQL
- React
- TypeScript
Use the follow mutation to submit a follow request.
Finally, handle the result as explained in the Transaction Lifecycle guide.
Unfollow an Account
To unfollow an account, you need to:
Check Unfollow permissions
Submit an Unfollow request
All steps in this section assumes are authenticated as Account Owner or Account Manager.
First, inspect the account's operations.canUnfollow field to determine if you can unfollow the account.
- GraphQL
- TypeScript
Account
fragment Account on Account { # ...
operations { # defaults to the Global Graph canUnfollow isFollowedByMe
# or use aliases for a specific Graph # canUnfollowOnMyGraph: canUnfollow(request: { graph: "0x123…" }) # isFollowedByMeOnMyGraph: isFollowedByMe(request: { graph: "0x123…" }) }}
If true, you can unfollow the account. If false, you might not be following them, in which case the operation.isFollowedByMe field will also be false.
Then, if your unfollow request is allowed, you can proceed with submitting the request.
- GraphQL
- React
- TypeScript
Use the unfollow mutation to submit an unfollow request.
Finally, handle the result as explained in the Transaction Lifecycle guide.