Rich Text Field

Under the hood, we use Slate v0.5 for our rich-text editor.

Simple Single Line Query

Sample Rich Text Query - Text Response

{
products {
name
description {
text
}
}
}

Output

{
"data": {
"products": [
{
"name": "ACME Hammer",
"description": {
"text": "A really good hammer."
}
}
]
}
}

Sample Rich Text Query - Raw Response Returns the raw Slate AST

{
products {
name
description {
raw
}
}
}

Output

{
"data": {
"products": [
{
"name": "ACME Hammer",
"description": {
"raw": {
"children": [
{
"type": "paragraph",
"children": [
{
"text": "A really good hammer."
}
]
}
]
}
}
}
]
}
}

Sample Rich Text Query - HTML Response

{
products {
name
description {
html
}
}
}

Output

{
"data": {
"products": [
{
"name": "ACME Hammer",
"description": {
"html": "<p>A really good hammer.</p>"
}
}
]
}
}

Sample Rich Text Query - Markdown Response

{
products {
name
description {
markdown
}
}
}

Output

{
"data": {
"products": [
{
"name": "ACME Hammer",
"description": {
"markdown": "A really good hammer.\n"
}
}
]
}
}

Mutating Rich Text

We use Slate v0.5 for our rich-text editor. Please refer to the the Slate Docs for serializing data to send via your mutation.

Mutation

mutation {
createProduct(
data: {
name: "ACME Shovel"
description: {
children: [
{ type: "paragraph", children: [{ text: "A really good shovel." }] }
]
}
}
) {
name
description {
text
}
}
}

Output

{
"data": {
"createProduct": {
"name": "ACME Shovel",
"description": {
"text": "A really good shovel."
}
}
}
}

Were you expecting something more?

We are constantly contributing to our documentation, but if you spot something we're missing, let us know and we'll be sure to add it.

This site uses cookies to provide you with a better user experience. For more information, refer to our Privacy Policy