Has collected publication

You need to know if the logged-in user has collected a publication it's viewing, to do this you need to look at the hasCollectedByMe property on the publication response. This is shown in the examples when fetching back a publication. It will always be false if calling when not logged in but when passing in the auth header it will work out if that wallet has collected it already.

API Design basic

please note the example below doesn't pick all the content out of the publication it just shows you the field used to get that back.

query Publications {
  publications(request: {
    profileId: "0x09",
    publicationTypes: [POST, COMMENT, MIRROR],
    limit: 10,
  }) {
    items {
      __typename 
      ... on Post {
        hasCollectedByMe
      }
      ... on Comment {
        hasCollectedByMe
      }
      ... on Mirror {
        hasCollectedByMe
      }
    }
    pageInfo {
      prev
      next
      totalCount
    }
  }
}

Did this page help you?