Communications
APIs for content creation and management such as email, templates, mobile/feed posts, delivery, and more.
Feeds Example Queries
Overview
This guide follows on from the Integrating with a Feed guide to offer a number of example Content API GraphQL queries.
These queries are production ready examples based directly on the queries used by Poppulo for the SharePoint-Teams Content Feed Reader.
Landing Page
To create a landing page use the getPosts query to retrieve posts from a feed filtered by FEATURED
and NONFEATURED
posts.
Note that this query uses pagination.
fragment ImageAll on Image {
url
public
}
fragment PostImageComponent on Components {
image {
...ImageAll
}
}
fragment VideoAll on Video {
type
url
authUrl
fileName
thumbnails
}
fragment PostVideoComponent on Components {
video {
...VideoAll
}
}
fragment LinkAll on Link {
logo
url
domain
}
fragment PostLinkComponent on Components {
link {
...LinkAll
}
}
fragment ReadingTime on ReadingTime {
time
}
fragment PostReadingTimeComponent on Components {
readingTime {
...ReadingTime
}
}
fragment PostPreview on Post {
id
body
author
featured
status
title
timeOfPublish
components {
...PostVideoComponent
...PostLinkComponent
...PostImageComponent
...PostReadingTimeComponent
}
employeeFeedGroup {
id
feedGroup {
name
}
}
}
query getPosts {
featured: getPosts(postType: FEATURED, first: 4) {
edges {
node {
...PostPreview
}
}
}
nonFeatured: getPosts(postType: NONFEATURED, first: 4) {
edges {
node {
...PostPreview
}
}
}
}
Employee Groups
To create an employee groups management page use the getEmployeeFeedGroupsByEmployeeId query to retrieve a list of the available groups for an employee. Note that this query uses pagination.
query getFeedGroups($after: String) {
getEmployeeFeedGroupsByEmployeeId(first: 50, after: $after) {
pageInfo {
endCursor
hasNextPage
}
edges {
node {
id
status
feedGroup {
name
}
}
cursor
}
}
}
Single Post
To create a single post page use the following queries to view the post, along with the post's comments and reactions.
- getPost query to retrieve the post itself.
- getReaction query to retrieve the reactions (likes) for the post.
- getPost query with the field
feedPostsComment
to retrieve five comments at a time.
Note that the queries use pagination.
getPost Example Query
fragment ImageAll on Image {
url
public
}
fragment PostImageComponent on Components {
image {
...ImageAll
}
}
fragment VideoAll on Video {
type
url
authUrl
fileName
thumbnails
}
fragment PostVideoComponent on Components {
video {
...VideoAll
}
}
fragment LinkAll on Link {
logo
url
domain
}
fragment PostLinkComponent on Components {
link {
...LinkAll
}
}
fragment ReadingTime on ReadingTime {
time
}
fragment PostReadingTimeComponent on Components {
readingTime {
...ReadingTime
}
}
fragment Attachment on Attachment {
fileName
type
url
}
fragment PostAttachmentComponent on Components {
attachments {
...Attachment
}
}
fragment PostFull on Post {
id
body
author
featured
status
title
timeOfPublish
reactionsEnabled
commentsEnabled
reactions {
likeCount
}
comments {
commentCount
}
components {
...PostVideoComponent
...PostLinkComponent
...PostImageComponent
...PostReadingTimeComponent
...PostAttachmentComponent
}
employeeFeedGroup {
id
feedGroup {
name
}
}
}
query getPost($postId: ID!) {
getPost(postId: $postId) {
...PostFull
}
}
getReaction Example Query
fragment ReactionStatusId on Reaction {
status
reactionId
}
query getReaction($postId: String!) {
getReaction(postId: $postId) {
...ReactionStatusId
}
}
getPost with feedPostComments Example Query
query getPostComments($postId: ID!, $after: String) {
getPost(postId: $postId) {
id
feedPostComments(first: 5, after: $after) {
edges {
node {
id
content
author
commentByUser
}
cursor
}
totalCount
pageInfo {
hasPreviousPage
hasNextPage
endCursor
startCursor
}
}
}
}
Posts in Group
To create a page showing the posts within a group use the getGroupPosts and getEmployeeFeedGroupByEmployeeId queries.
Note that this query uses pagination
fragment ImageAll on Image {
url
public
}
fragment PostImageComponent on Components {
image {
...ImageAll
}
}
fragment VideoAll on Video {
type
url
authUrl
fileName
thumbnails
}
fragment PostVideoComponent on Components {
video {
...VideoAll
}
}
fragment LinkAll on Link {
logo
url
domain
}
fragment PostLinkComponent on Components {
link {
...LinkAll
}
}
fragment ReadingTime on ReadingTime {
time
}
fragment PostReadingTimeComponent on Components {
readingTime {
...ReadingTime
}
}
fragment PostPreview on Post {
id
body
author
featured
status
title
timeOfPublish
components {
...PostVideoComponent
...PostLinkComponent
...PostImageComponent
...PostReadingTimeComponent
}
employeeFeedGroup {
id
feedGroup {
name
}
}
}
query ($groupId: ID!, $after: String) {
getGroupPosts(groupId: $groupId, first: 10, after: $after) {
pageInfo {
endCursor
hasNextPage
}
edges {
node {
...PostPreview
}
cursor
}
}
getEmployeeFeedGroupByEmployeeId(groupId: $groupId) {
id
status
feedGroup {
name
}
}
}