Guides

Has bookmarked publication

You need to know if a user has bookmarked a certain publication, to do this you need to look at the bookmarked property on the publication response.

In this field resolver you can pass in a profileId you wish to know the bookmark state for, most apps would use the logged in users selected profile they are browsing on.

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 {
        bookmarked(by: "0x01")
      }
      ... on Comment {
        bookmarked(by: "0x01")
      }
      ... on Mirror {
        bookmarked(by: "0x01")
      }
    }
    pageInfo {
      prev
      next
      totalCount
    }
  }
}

profileId for bookmarked can pass in as a variable easily enough as well. You can imagine passing the logged-in user's profile they are browsing on to see if they have bookmarked the publication. This can be hooked in like this for every query which returns a publication type (Post or Comment or Mirror)

query Publications($publicationsRequest: PublicationsQueryRequest!, $profileId: ProfileId) {
  publications(request: $publicationsRequest) {
    items {
      __typename 
      ... on Post {
        bookmarked(by: $profileId)
      }
      ... on Comment {
        bookmarked(by: $profileId)
      }
      ... on Mirror {
        bookmarked(by: $profileId)
      }
    }
    pageInfo {
      prev
      next
      totalCount
    }
  }
}

Or, for a specific publication:

query Publication {
  publication(request: {
    publicationId: "0x01-0x01"
  }) {
   __typename 
    ... on Post {
      bookmarked(by: "0x01")
    }
  }
}