Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,212 of 9,212 pages
About the help in other languages
All help pages

Datatypes in GraphQL

What this is. For every datatype of the kernel and of the bundled extensions: the GraphQL type a field of that datatype has when you read it, an example query, and the string format a mutation writes with…

Download as PDF

Address: https://doc.exponential.earth/learninminutes/exphelp/viewer/headless/datatypes.md

On this page

Datatypes in GraphQL

What this is. For every datatype of the kernel and of the bundled extensions: the GraphQL type a field of that datatype has when you read it, an example query, and the string format a mutation writes with FieldInput.value.

When to use it. When you select a field of a class type, generate TypeScript types, render a field, or fill fields: of createContent, updateContent or translateContent.

Quick example: an image, a rich text and a relation list of one article.

{
  node(urlAlias: "fitness/ten-minutes-a-day") {
    ... on ng_article {
      image { url(alias: "medium") width(alias: "medium") height(alias: "medium") alt }
      body { html excerpt(length: 120) }
      related_content { name url }
    }
  }
}

Contents

  1. How a datatype becomes a field
  2. The table
  3. Reading, datatype by datatype
  4. Writing fields
  5. Datatypes without a mapping
  6. Datatypes of schema extensions
  7. Empty values and null

How a datatype becomes a field

Every attribute of a class shown in the schema is a field of the class type. Its GraphQL type comes from its datatype (expGraphQLFieldMapper):

  1. A schema extension that names the datatype (expGraphQLSchemaExtension::datatypes()) maps it first (eztags gives [Tag!]!).
  2. The kernel maps 39 datatypes (the table below).
  3. Any other datatype is a String with the field's text form (its toString()), so every attribute is in the schema. ./console exp:graphql:status and exp:graphql:schema --format=summary list the datatypes that fall back.

The description of each field in the schema is <attribute name>: <description> (<datatype>), so a schema browser shows the datatype of every field. contentClasses { fields { datatype graphqlType mapped } } gives the same as data.

Attributes of HiddenFieldList[] and datatypes of HiddenDatatypeList[] (ezuser, ezpassword) are not in the schema at all: they can be neither read nor written.

The table

DatatypeGraphQL type (read)Write with value (FieldInput)
ezstringStringthe text
eztextStringthe text (line breaks kept)
ezemailStringthe address (no control characters)
ezisbnStringthe ISBN
ezidentifierStringthe identifier (normally made by the kernel)
ezintegerIntdigits, optionally with a minus: "42"; "" for no value
ezfloatFloata finite number: "3.5"; "" for no value
ezbooleanBoolean"1" or "0" (other text is mapped to 1 or 0)
ezdateString 2026-10-29a Unix timestamp: "1793232000"; "" for no date
ezdatetimeString ISO 8601 2026-10-29T09:15:00+01:00a Unix timestamp; "" for none
eztimeString 13:45:00"13:45" or "13:45:00"
ezxmltextRichTextthe stored XML (format: RAW), plain text (TEXT) or simple HTML (HTML)
ezimageImagean upload; value is then the alternative text
ezbinaryfileBinaryFilean upload; value the file name
ezmediaBinaryFilean upload
ezpricePrice"<price>|<VAT type id>|<1 VAT included, 0 excluded>": "19.90|1|1"
ezurlLink"<url>" or "<url>|<text>"; a script URL is refused
ezselection[SelectionOption!]!the option names, |-separated: "Red|Blue"
ezcountry[Country!]!the stored country value, comma separated as the datatype stores it ("NO,DE")
ezkeyword[String!]!the keywords, comma separated: "running, fitness"
ezauthor[Author!]!"<name>|<email>|<id>" per author, authors separated by &
ezmatrixMatrixrows separated by &, cells by |, row after row
ezobjectrelationContentthe object id: "57"; "" removes the relation
ezobjectrelationlist[Content!]!object ids separated by -: "57-58-59"
ezgmaplocationGeoLocation"1|#<latitude>|#<longitude>|#<address>"
ezsrratingRating(votes are not written through GraphQL)
xrowmetadataMetadatathe datatype's stored text form
ngenhancedlinkEnhancedLinkthe stored JSON of the link
sckenhancedselection[String!]!one identifier, or the serialized PHP array the datatype stores
ngclasslist[String!]!class identifiers, comma separated: "article,blog_post"
ezoptionOptionList"<name>|<value>|<additional price>|<value>|<additional price>..."
ezmultioption[OptionGroup!]!"<name>&<group>|..." as the datatype exports it
ezrangeoptionRange"<name>|<start>|<stop>|<step>"
ezmultiprice[CurrencyPrice!]!"<VAT type>|<VAT ex/inc>|<currency>|<value>|<type>|..."
ezenum[EnumValue!]!(as the datatype's import reads it)
ezsubtreesubscriptionBoolean"1" or "0"
ezinisettingStringthe text form
ezpackageStringthe text form
ezproductcategoryString (the category's name)the category as the datatype reads it
eztags (extension)[Tag!]!"<ids>|#<keywords>|#<parent ids>|#<locales>", each part listing every tag, |#-separated

The value strings are the same the kernel's CSV import and eZContentObjectAttribute::fromString() read; the datatype checks them and refuses a value it cannot store ("The value of the field … could not be stored.", BAD_USER_INPUT). When in doubt, read the field of an existing object with the console, which prints the text form: ./console exp:graphql:query '{ content(id: 57) { ... on ng_article { title teaser_title } } }'.

Reading, datatype by datatype

Text: ezstring, eztext, ezemail, ezisbn, ezidentifier

String, null when empty.

{ content(id: 57) { ... on ng_article { title teaser_title } } }

Numbers and booleans: ezinteger, ezfloat, ezboolean, ezsubtreesubscription

Int, Float (null when empty), Boolean (never null for ezboolean: an empty one is false).

Dates and times: ezdate, ezdatetime, eztime

DatatypeExampleNotes
ezdate"2026-10-29"the date only, in the server's time zone
ezdatetime"2026-10-29T09:15:00+01:00"PHP's date('c'): ISO 8601 with the server's offset
eztime"13:45:00"the time of day

Content.published and modified have the ezdatetime format. Parse them with new Date(value) in JavaScript; the offset keeps them exact. An unset date is null.

Rich text: ezxmltext → RichText

type RichText { html: String  text: String  xml: String  excerpt(length: Int = 200): String }
  • html: rendered as the site renders it (the siteaccess's templates for custom tags and embeds). Links to content are site addresses of the siteaccess that answers.
  • text: plain text, for search snippets, meta descriptions, voice.
  • xml: the stored XML, for your own renderer (@exponentialcms/richtext parses it into a typed tree and renders HTML, text or Markdown with your own links and embeds).
  • excerpt(length:): the start of the plain text, cut at a word, at most length characters.
{ node(urlAlias: "about") { ... on ng_landing_page { full_intro { html text excerpt(length: 160) } } } }

Use html when your front end may show the site's markup; use xml with your own renderer when it must control every element (a native app, a strict design system).

Images: ezimage → Image

type Image {
  url(alias: String = "original"): String
  width(alias: String = "original"): Int
  height(alias: String = "original"): Int
  mimeType(alias: String = "original"): String
  alt: String
  variations(aliases: [String!]): [ImageVariation!]!
}
type ImageVariation { alias: String!  url: String  width: Int  height: Int  mimeType: String }
  • An alias is any alias of image.ini [AliasSettings] AliasList[]; original is the uploaded file. An unknown alias answers BAD_USER_INPUT ("There is no image alias …").
  • variations without aliases lists graphql.ini ImageAliasList[] (small, medium, large by default).
  • Aliases are made when first asked for. The address may be a signed on-demand address, https://<host>/content/image/<payload>.<signature>/<name>_<alias>.<ext>; use it exactly as given.
  • Use width and height for the width/height attributes of <img>, so the page does not jump.
{
  node(urlAlias: "recipes/power-up-smoothie") {
    ... on ng_recipe {
      image {
        alt
        small: url(alias: "small")
        medium: url(alias: "medium")
        large: url(alias: "large")
        width(alias: "large") height(alias: "large")
        variations(aliases: ["small", "medium", "large"]) { alias url width height }
      }
    }
  }
}

With the SDK, imageAttributes(image, 'medium', { srcSetAliases: ['medium', 'large'], sizes: '50vw' }) makes the attributes of an <img> with a srcset from variations; see the cookbook recipe Responsive images.

Files: ezbinaryfile, ezmedia → BinaryFile

type BinaryFile { fileName: String  mimeType: String  size: Int  url: String }

url is the download address of the siteaccess (/content/download/<object>/<attribute>/file/<name>), which checks the reader's rights again when it is fetched: an anonymous visitor cannot download a file the role Anonymous may not read, even with the address.

Prices: ezprice → Price, ezmultiprice → [CurrencyPrice!]!

type Price { price: Float  incVat: Float  exVat: Float  vatPercent: Float }
type CurrencyPrice { currency: String!  value: Float  type: Int }
type Link { url: String  text: String }
type EnhancedLink { type: String  url: String  label: String  target: String  suffix: String  rel: String  content: Content }

EnhancedLink.type is internal or external; for an internal link content is the linked content when the user may read it and url its address in this siteaccess, with suffix (#part, ?query) added. target is how the link opens (link, link_new_tab, modal, embed).

Choices: ezselection, ezcountry, sckenhancedselection, ngclasslist, ezenum

type SelectionOption { id: Int!  name: String }
type Country { code: String!  name: String }
type EnumValue { element: String  value: String }

ezselection is the list of chosen options ([SelectionOption!]!, empty when none). The options a class offers are in contentClasses { fields { options { id name } } }. sckenhancedselection and ngclasslist are lists of identifiers.

Keywords and authors: ezkeyword → [String!]!, ezauthor → [Author!]!

Author has only name: e-mail addresses are personal data and are not exposed.

Relations: ezobjectrelation → Content, ezobjectrelationlist → [Content!]!

Related content at its main location, only what the user may read: a related object the user may not read is null (single) or left out (list). The related objects of a whole page are fetched together (one batch per level of the query), so a listing of 50 articles with their authors costs a few queries, not 50.

{
  children(parentId: 92, classes: ["ng_article"], limit: 20) {
    nodes { name ... on ng_article { authors { name url } related_content { name url classIdentifier } } }
  }
}

The matrix: ezmatrix → Matrix

type Matrix { columns: [String!]!  rows: [[String]!]! }

columns are the column names; each row is a list of cell texts in column order.

Maps, ratings, metadata

type GeoLocation { latitude: Float  longitude: Float  address: String }
type Rating { average: Float  count: Int! }
type Metadata { title: String  description: String  keywords: [String!]!  priority: String  change: String  sitemapUse: Boolean  canonicalUrl: String }

Rating.average is rounded to two decimals and null with no votes. Metadata (xrowmetadata) is what search engines and sitemaps read; see the cookbook recipe An XML sitemap.

Shop options: ezoption, ezmultioption, ezrangeoption

type OptionList { name: String  options: [Option!]! }
type OptionGroup { name: String  options: [Option!]! }
type Option { id: Int  value: String  additionalPrice: Float }
type Range { name: String  start: Float  stop: Float  step: Float }

Writing fields

Fields are written with FieldInput:

input FieldInput {
  identifier: String!          # the attribute identifier
  value: String                # the value in the datatype's string format (the table above)
  format: FieldFormat = RAW    # rich text only: RAW, TEXT, HTML
  upload: Upload               # a file of a multipart request, for file fields
}

Rules, checked before anything is written (BAD_USER_INPUT otherwise):

  1. The identifier is an attribute of the class the schema shows (hidden fields and datatypes cannot be written).
  2. Each identifier at most once.
  3. File datatypes (ezimage, ezbinaryfile, ezmedia, and the datatypes of FileDatatypeList[]) take upload, never a path in value: a path would let a client import any file of the server.
  4. Other datatypes take value and no upload.
  5. format other than RAW only for rich text (ezxmltext).
  6. createContent needs every required attribute; updateContent writes only the fields given, the others keep their value; translateContent copies the main language and overwrites the fields given.

Rich text formats:

formatvalueResult
RAWthe stored XML of the kernel (<?xml ...><section ...><paragraph>...</paragraph></section>)stored as it is (validated by the datatype)
TEXTplain text; blocks separated by an empty lineone paragraph per block, whitespace in a block collapsed, special characters escaped
HTMLsimple HTML: p, h1-h6, strong, em, a, ul, ol, li, table ...converted by the kernel's HTML input parser (as the editor's paste); unreadable HTML: "The HTML could not be read."

Examples:

mutation {
  updateContent(id: 1504, fields: [
    { identifier: "title", value: "Power-up Smoothie" }
    { identifier: "servings", value: "2" }
    { identifier: "vegan", value: "1" }
    { identifier: "publish_date", value: "1793232000" }
    { identifier: "keywords", value: "smoothie, breakfast, vegan" }
    { identifier: "related_content", value: "1483-1490" }
    { identifier: "link", value: "https://www.example.org/smoothies|More smoothies" }
    { identifier: "intro", value: "A quick start.\n\nReady in five minutes.", format: TEXT }
    { identifier: "body", value: "<h2>Steps</h2><ol><li>Blend</li><li>Serve</li></ol>", format: HTML }
  ]) { status version }
}

Replace the identifiers with those of your class: contentClasses(identifiers: ["ng_recipe"]) { fields { identifier datatype required } } lists them.

Files travel in a multipart request; value of the same FieldInput is the alternative text (images) or the file name. See GraphQL API reference, "Uploads".

Datatypes without a mapping

A datatype the kernel does not map and no schema extension maps is a String with the field's text form (toString()), and is written with the same text form (fromString()). It works, but it is untyped: map it in a schema extension when clients need its structure (see the Maintainer guide, "Adding a datatype").

Datatypes of schema extensions

ExtensionDatatypeType
eztags (expGraphQLTagsExtension)eztags[Tag!]! (keywords in the translation read when they have one)

An extension of your own adds its datatypes the same way; the schema hash changes when it is added.

Empty values and null

DatatypeEmpty field reads as
text, numbers, dates, RichText, Image, BinaryFile, Link, Matrix, GeoLocation, Metadata, Price, OptionList, Range, EnhancedLink, single relationnull
ezboolean, ezsubtreesubscriptionfalse
lists (ezselection, ezkeyword, ezauthor, relation lists, ezcountry, ezmultioption, ezmultiprice, ezenum, eztags, sckenhancedselection, ngclasslist)[]
ezsrrating{ average: null, count: 0 }

Write "" to empty most fields (an integer, a float, a date, a relation).

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x