GraphQL

Interfaces & Types

A Vizy field's GraphQL value is a document object, which gives access to the document's nodes. Each node implements VizyNodeInterface, each block also implements VizyBlockInterface, and the formatting on text implements VizyMarkInterface. Queries shows how to request them through Craft's element queries.

In the types below, a ! marks a value that is never null and square brackets mark a list.

Document Types

The VizyDocument Type

Each Vizy field returns its own document type, named after the field's handle, such as vizyField_VizyDocument. The type is generated per field so that its blocks only include the Block Types that field allows. Every document type has these fields.

schemaVersion

The version of the stored document format, currently 2.

nodes

The document's root nodes in order. Prose and enabled blocks are included by default. Accepts where: ArrayType, limit: Int and orderBy: String, described in Root Nodes.

vizyField {
  nodes(where: { enabled: null }, limit: 10) {
    type
    html
  }
}

blocks

The document's blocks in order, including blocks inside layout columns. Blocks inside a nested Vizy field are queried through that field. Accepts the same where, limit and orderBy arguments as nodes.

vizyField {
  blocks(where: { handle: "callout" }) {
    uid
    blockTypeHandle
  }
}

block

The block with the instance UID passed as the required uid: ID! argument, or null when the document has no block with that UID.

vizyField {
  block(uid: "4f0f7e2a-8c1d-4c55-9a4e-0b6f2d1c9e11") {
    blockTypeHandle
  }
}

raw

The complete stored document as a JSON-encoded string. Review Data Access and Permissions before exposing it.

renderedHtml

The document rendered as HTML, the same output as {{ entry.vizyField.render() }} in Twig.

The ArrayType Scalar

Vizy uses the ArrayType scalar for JSON-shaped values. As an argument, such as where, it accepts inline object and list literals, null, or a variable. As a returned value, such as raw, attrs or rawFieldValues, it's a JSON-encoded string with no nested selection, so decode it in your client before reading its properties.

Node Types

The VizyNodeInterface Interface

Every node implements this interface, including prose, layouts, blocks and nodes from extensions that aren't installed. Select these fields directly inside nodes or children.

type

The node type, such as paragraph, heading, image or vizyBlock.

attrs

The node's attributes as a JSON-encoded string, such as {"level":2} for a level 2 heading.

marks

The formatting marks applied to the node. Marks are usually found on text nodes, the children of a paragraph or heading.

children

The node's child nodes in order. Blocks always return an empty list, so query the content of a block's nested Vizy field through that field.

nodes(where: { type: "bulletList" }) {
  children {
    text
  }
}

text

The text of a text node, or the joined text of every descendant for a container such as a paragraph. Returns null when the node has no text, such as an image or a block.

html

The node rendered as HTML, using the same rules as the document's renderedHtml.

raw

The node's stored JSON as a JSON-encoded string.

isUnknown

Whether the node's type has no installed extension, such as a node added by a plugin that has since been removed. These nodes use the VizyUnknownNode type.

Generated Node Types

Each node type registered with Vizy, including custom nodes, gets an object type named Vizy followed by its type in Pascal case. A paragraph node is VizyParagraph, a bulletList is VizyBulletList and a custom emoji node is VizyEmoji. Most node types have only the interface fields. The following types add their own.

The VizyImage Type

asset

The image's asset. Returns null when the asset doesn't exist or the schema can't query its volume.

... on VizyImage {
  asset {
    url @transform(width: 1200)
    alt
  }
}

The VizyLayout Type

uid

The layout's UID.

stack

The setting for when the layout's columns should stack, small by default. Vizy outputs it as a data-stack attribute, and your stylesheet decides which breakpoint each value represents.

columns

The layout's columns, each a VizyColumn.

... on VizyLayout {
  stack
  columns {
    ... on VizyColumn {
      span
      proportion
      children {
        type
        html
      }
    }
  }
}

The VizyColumn Type

uid

The column's UID.

span

The number of the layout's 12 grid columns this column spans.

proportion

The column's span divided by 12, as a decimal string such as 0.5 or 0.3333. It's calculated from span rather than stored.

The VizyFootnoteReference and VizyFootnoteItem Types

footnoteUid

The UID that pairs a footnote reference with its definition.

number

The footnote's number, starting at 1 and calculated from the order of references in the document.

definition

The paired footnote definition, a VizyFootnoteItem. Only VizyFootnoteReference has this field.

Block Types

The VizyBlockInterface Interface

Every block implements this interface, which includes all the VizyNodeInterface fields as well as these.

uid

The block's instance UID, which you can pass to the document's block field.

blockTypeUid

The UID of the block's Block Type.

blockTypeHandle

The handle of the block's Block Type. Returns null when the Block Type can't be found.

enabled

Whether the block is enabled.

resolved

Whether the block's Block Type and its field layout can be found. An unresolved block uses the VizyUnresolvedBlock type, which has only the interface fields.

rawFieldValues

The block's stored field values as a JSON-encoded string, keyed by field placement UID, including the documents of nested Vizy fields. Review Data Access and Permissions before exposing it.

Generated Block Types

Each Block Type has its own object type, which adds the custom fields from the Block Type's field layout. The name is the Block Type's handle in Pascal case, followed by the first eight characters of its UID and _VizyBlock, such as Callout_a1b2c3d4_VizyBlock. Find the exact name in GraphiQL's schema explorer.

Custom fields return the same GraphQL types they do on an entry, so a relation field accepts the usual arguments and a nested Vizy field returns another document.

blocks {
  ... on Callout_a1b2c3d4_VizyBlock {
    heading
    image {
      url
    }
    body {
      renderedHtml
    }
  }
}

Mark Types

The VizyMarkInterface Interface

Every formatting mark on a text node implements this interface.

type

The mark type, such as bold, italic or link.

attrs

The mark's attributes as a JSON-encoded string.

raw

The mark's stored JSON as a JSON-encoded string.

isUnknown

Whether the mark's type has no installed extension. These marks use the VizyUnknownMark type.

Generated Mark Types

Each mark type gets an object type named Vizy followed by its type in Pascal case, such as VizyBold or VizyTextStyle. Only VizyLink adds its own fields.

element

The linked entry, asset or category. Returns null for other link types, and when the element is unavailable or the schema can't query it.

url

The link's URL. For an element link, this is the element's URL with any suffix added, and it's null when element would be null. For a URL, email, phone or SMS link, it's the same href Vizy renders in Twig.

marks {
  ... on VizyLink {
    url
    element {
      title
    }
  }
}