Guides

Reactions

You can add or remove reactions. You can fetch who reacted to a publication.

Reactions are stored offchain so there is no need for signatures or gas required to add a reaction.

Add reaction

🚧

This Request is Protected by Authentication

Request

ReactionRequest

Invocation

import { PublicationReactionType } from '@lens-protocol/client';

await client.publication.reactions.add({
  for: '0x02-0x01',
  reaction: PublicationReactionType.Upvote,
});
mutation AddReaction($request: ReactionRequest!) {
  addReaction(request: $request)
}

Response

Returns a Void.

Remove reaction

🚧

This Request is Protected by Authentication

Request

ReactionRequest

Invocation

import { PublicationReactionType } from '@lens-protocol/client';

await client.publication.reactions.remove({
  for: '0x02-0x01',
  reaction: PublicationReactionType.Upvote,
});
mutation RemoveReaction($request: ReactionRequest!) {
  removeReaction(request: $request)
}

Response

Returns a Void.

Fetch profiles who reacted to a publication

Fetch all profiles that have reacted to a publication.

Request

WhoReactedPublicationRequest

Invocation

const profilesWhoReacted = await client.publication.reactions.fetch({
  for: '0x02-0x01',
});
fragment ProfileReactionResult on ProfileReactionResult {
  reaction
  reactionAt
}

fragment ProfileWhoReactedResult on ProfileWhoReactedResult {
  profile {
    ...Profile
  }
  reactions {
    ...ProfileReactionResult
  }
}

query WhoReactedPublication($request: WhoReactedPublicationRequest!) {
  result: whoReactedPublication(request: $request) {
    items {
      ...ProfileWhoReactedResult
    }
    pageInfo {
      ...PaginatedResultInfo
    }
  }
}

Response

Paginated result with ProfileWhoReactedResult

Full GraphQL API Examples

📘

Add Reaction: GraphQL API Full Example

📘

Remove Reaction: GraphQL API Full Example

📘

Who Reacted To a Publication: GraphQL API Full Example