Recipes

A list of common use case to handle with GraphQL API.

Create a live contribution

To create a live contribution, you have to use CreateLiveContribution mutation.

You have to know the live ID, we use "bG9jYWw6TGl2ZTox" as live ID in this example.

Copy/paste this mutation to Sirius GraphQL Playground and execute it.

mutation CreateLiveContribution(
$liveId: "bG9jYWw6TGl2ZTox"
$text: "I Will Find You And I Will Kill You",
$authorName: "Chris Hardwick",
$authorEmail: "c.hardwick@gmail.com"
) {
createLiveContribution(
input: {
liveId: $liveId
text: $text
authorName: $authorName
authorEmail: $authorEmail
}
) {
id
}
}

Note that we choose to return the id because we have to return at least one field in a GraphQL type.

Query layouts "id" and "names"

To list all layouts, uses articleLayouts query.

The query articleLayouts returns a ArticleLayoutConnection which contains nodes.

Copy/paste this query to Sirius GraphQL Playground and execute it.

query Layouts {
articleLayouts {
nodes {
id
name
}
}
}

The returned data should have the following shape:

{
"data": {
"articleLayouts": {
"nodes": [
{
"id": "bG9jYWw6TGF5b3V0Ojk=",
"name": "Sirius Live"
},
{
"id": "bG9jYWw6TGF5b3V0OjE=",
"name": "Article"
}
]
}
}
}

Import an article

This GitHub project is a step-by-step tutorial to help you import an Article in Sirius using GraphQL API. It is written in JavaScript but the method is the same for every language.

Suggest medias for an article

To suggest a media for an article, uses createOrUpateMedias mutation.

The mutation createOrUpateMedias returns an array of Block.

Copy/paste this mutation to Sirius GraphQL Playground and execute it.

mutation CreateOrUpateMedias($input: CreateOrUpdateMediasInput!) {
createOrUpateMedias(input: $input) {
id
type
}
}

with variables:

{
"input": {
"articleId": "bG9jYWw6QXJ0aWNsZToxMjA1",
"medias": [
{
"type": "article",
"articleBlock": {
"articleId": "bG9jYWw6QXJ0aWNsZToxMjAz"
}
},
{
"type": "content",
"contentBlock": {
"contentId": "bG9jYWw6Q3VzdG9tVHlwZUNvbnRlbnQ6MTQ"
}
},
{
"type": "image",
"imageBlock": {
"imageView": {
"imageId": "bG9jYWw6SW1hZ2U6MTA4NQ"
}
}
}
]
}
}

Suggested media for an article can also be managed using the medias key in the createArticle and updateArticle mutations. In this case, any media not included in the medias array will be removed from the article. If an empty array is passed, all unused media will be removed.

Edit this page on GitHub