GraphQL#

Social Feeds supports accessing Feed and Source objects via GraphQL, along with Post objects. Be sure to read about Craft's GraphQL support (opens new window).

Feeds#

Example#

{
    socialShare {
        feeds(handle: ["myFeed", "myOtherFeed"]) {
            handle
        }

        feed(handle: "myFeed") {
            name
            handle
            enabled

            sources {
                name
            }
        }
    }
}
{
    "data": {
        "socialFeeds": {
            "feeds": [
                {
                    "handle": "myFeed"
                },
                {
                    "handle": "myOtherFeed"
                }
            ],
            "feed": {
                "name": "My Feed",
                "handle": "myFeed",
                "enabled": true,
                "sources": [
                    {
                        "name": "My Source"
                    }
                ]
            }
        }
    }
}

The feeds query#

This query is used to query Feed objects. You can also use the singular feed to fetch a single Feed.

ArgumentTypeDescription
id[Int]Narrows the query results based on the feeds’s ID.
handle[String]Narrows the query results based on the feeds’s handle.
uid[String]Narrows the query results based on the feeds’s UID.
limitIntSets the limit for paginated results.

The FeedInterface interface#

This is the interface implemented by all feeds.

FieldTypeDescription
nameStringThe feed’s name.
handleStringThe feed’s handle.
enabledBooleanWhether the feed is enabled.
sources[SourceInterface]The feed’s sources.

Sources#

Example#

{
    socialShare {
        sources(handle: ["mySource", "myOtherSource"]) {
            handle
        }

        source(handle: "mySource") {
            name
            handle
            enabled

            posts {
                id
                text
            }
        }
    }
}
{
    "data": {
        "socialFeeds": {
            "sources": [
                {
                    "handle": "mySource"
                },
                {
                    "handle": "myOtherSource"
                }
            ],
            "source": {
                "name": "My Feed",
                "handle": "mySource",
                "enabled": true,
                "posts": [
                    {
                        "id": "900949524373003",
                        "text": "Just a sample post."
                    }
                ]
            }
        }
    }
}

The sources query#

This query is used to query Source objects. You can also use the singular source to fetch a single Source.

ArgumentTypeDescription
id[Int]Narrows the query results based on the sources’s ID.
handle[String]Narrows the query results based on the sources’s handle.
uid[String]Narrows the query results based on the sources’s UID.
limitIntSets the limit for paginated results.

The SourceInterface interface#

This is the interface implemented by all feeds.

FieldTypeDescription
nameStringThe source’s name.
handleStringThe source’s handle.
enabledBooleanWhether the source is enabled.
dateLastFetchDateTimeThe date of the last time Posts were fetched.
providerNameStringThe name of the source provider connected.
providerHandleStringThe handle of the source provider connected.
primaryColorStringThe primary brand color of the provider connected.
iconStringThe SVG icon of the source provider connected.
isConnectedBooleanWhether the source provider has been connected and has a token.
posts[PostInterface]The source’s posts.

Posts#

Example#

{
    socialShare {
        sources(handle: ["mySource", "myOtherSource"]) {
            posts {
                id
                text
            }
        }
    }
}
{
    "data": {
        "socialFeeds": {
            "posts(limit: 10)": [
                {
                    "id": "900949524373003",
                    "text": "Just a sample post."
                }
            ]
        }
    }
}

The posts query#

This query is used to query Post objects. It must be called from a SourceInterface, or a FeedInterface.

ArgumentTypeDescription
limitIntSets the limit for paginated results.
offsetIntSets the offset for paginated results.

The PostInterface interface#

This is the interface implemented by all posts.

FieldTypeDescription
titleStringThe post’s title.
textStringThe post’s text.
urlStringThe post’s url.
sourceIdIntThe post’s source ID.
sourceHandle StringThe post’s source handle.
sourceTypeStringThe post’s source type.
postTypeStringThe post’s type.
likesIntThe post’s number of likes.
sharesIntThe post’s number of shares.
repliesIntThe post’s number of replies.
dateCreatedDateTimeThe post’s created date.
dateUpdatedDateTimeThe post’s updated date.
authorPostAuthorThe post’s author.
tagsStringThe post’s tags as a JSON string.
links[PostLink]The post’s links.
images[PostMedia]The post’s images.
videos[PostMedia]The post’s videos.
dataStringThe post’s raw data as a JSON string.
metaStringThe post’s meta data as a JSON string.

The PostAuthorInterface interface#

This is the interface implemented by post authors.

FieldTypeDescription
idStringThe post author’s ID.
usernameStringThe author’s username.
nameStringThe author’s name.
urlStringThe author’s url.
photoStringThe author’s photo.

The PostLinkInterface interface#

This is the interface implemented by post links.

FieldTypeDescription
idStringThe post link’s ID.
titleStringThe link’s title.
urlStringThe link’s url.

The PostMediaInterface interface#

This is the interface implemented by post media items.

FieldTypeDescription
idStringThe post media’s ID.
titleStringThe post media’s title.
typeStringThe post media’s type.
urlStringThe post media’s url.
widthIntThe post media’s width.
heightIntThe post media’s height.

Previous ← Events Next Console Commands →