Profile Operations
Query the state of different profile based operations.
The Profile
type contains a operations
field which includes the state of different operations that can be performed on a profile based on the currently authenticated profile.
For example:
jane.lens
viewsjohn.lens
's profile in any app that is integrated with Lens Protocol- to get the data for
john.lens
's profile, the app will call a method that returns aProfile
type - the
Profile
type will contain aoperations
field which will contain the state of different operations that can be performed onjohn.lens
's profile based on the currently authenticated profile (jane.lens
) - the app can use this data to determine how to display different elements of it's UI to
jane.lens
(e.g. using theProfile.operations.isFollowedByMe
field, the app can make a decision on how to render the follow/unfollow button)
The operation
fields are available on all methods that contain Profile
types in their response but here we will explore this in detail.
Invocation
The operations
field is available on all methods that return a Profile
type. For example, profile methods like profile.fetch
, profile.fetchAll
etc. and publication methods like publication.fetch
, publication.fetchAll
etc. where the profile is included in the response.
const { operations } = await lensClient.profile.fetch({
profileId: "PROFILE_ID",
})
query Profile {
profile(request: { profileId: "PROFILE_ID" }) {
# other profile fields are available
operations {
# ...ProfileOperations
}
}
}
Response
{
// ...other profile fields are available
"operations": {
"isFollowedByMe": {
"value": true,
"isFinalisedOnchain": true
},
"isBlockedByMe": {
"value": true,
"isFinalisedOnchain": true
},
"isFollowingMe": {
"value": true,
"isFinalisedOnchain": true
},
"canFollow": "YES", // YES | NO | UNKNOWN
"canUnfollow": false,
"canBlock": true,
"canUnblock": false
}
}
Updated about 1 month ago