Skip to main content

Creating a new internal custom field in administration panel

In this guide we will see how you can create a new custom field and how browse it with GraphQL API.

Introduction​

For this example, we will see how to add a custom twitter username text field on Authors.

Creating a new custom field​

  1. Login to Sirius, if you don't have an account, ask a Sirius owner to create one for you.
  2. Be sure your user has the "customFields:full", usually the "Owner" role.
  3. Go to administration custom fields page. Administration ‣ Champs personnalisés
  4. Click Signataire then Créer un champ personnalisé

Create custom field

Update custom field value​

  1. Once twitter had been created, go to the author page. Administration ‣ Signataires ‣ Pick one
  2. Fill new twitter text custom field
  3. Save the author

Retrieve twitter from authors​

You can query this specific author's custom field by a simple call to the GraphQL API (see forming-calls and Author)

query Author {
node(id: "c3RnLWxlbW9uZGU6Q3VzdG9tRmllbGQ6MzY=") {
... on Author {
id
custom {
twitter
}
}
}
}

With AuthorCustomFields:

type AuthorCustomFields {
twitter: String
}

The result of this query is an Author object with twitter custom field as text:

{
"data": {
"node": {
"id": "c3RnLWxlbW9uZGU6Q3VzdG9tRmllbGQ6MzY=",
"custom": { "twitter": "@foobar" }
}
}
}

As you can see, types are generated automatically based on your Sirius configuration. Don't forget to check Sirius GraphQL Playground to see updated schema that displays custom fields.

Sirius GraphQL Playground