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
- How a datatype becomes a field
- The table
- Reading, datatype by datatype
- Writing fields
- Datatypes without a mapping
- Datatypes of schema extensions
- 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):
- A schema extension that names the datatype (
expGraphQLSchemaExtension::datatypes()) maps it first (eztags gives[Tag!]!). - The kernel maps 39 datatypes (the table below).
- Any other datatype is a
Stringwith the field's text form (itstoString()), so every attribute is in the schema../console exp:graphql:statusandexp:graphql:schema --format=summarylist 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
| Datatype | GraphQL type (read) | Write with value (FieldInput) |
|---|---|---|
ezstring | String | the text |
eztext | String | the text (line breaks kept) |
ezemail | String | the address (no control characters) |
ezisbn | String | the ISBN |
ezidentifier | String | the identifier (normally made by the kernel) |
ezinteger | Int | digits, optionally with a minus: "42"; "" for no value |
ezfloat | Float | a finite number: "3.5"; "" for no value |
ezboolean | Boolean | "1" or "0" (other text is mapped to 1 or 0) |
ezdate | String 2026-10-29 | a Unix timestamp: "1793232000"; "" for no date |
ezdatetime | String ISO 8601 2026-10-29T09:15:00+01:00 | a Unix timestamp; "" for none |
eztime | String 13:45:00 | "13:45" or "13:45:00" |
ezxmltext | RichText | the stored XML (format: RAW), plain text (TEXT) or simple HTML (HTML) |
ezimage | Image | an upload; value is then the alternative text |
ezbinaryfile | BinaryFile | an upload; value the file name |
ezmedia | BinaryFile | an upload |
ezprice | Price | "<price>|<VAT type id>|<1 VAT included, 0 excluded>": "19.90|1|1" |
ezurl | Link | "<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 & |
ezmatrix | Matrix | rows separated by &, cells by |, row after row |
ezobjectrelation | Content | the object id: "57"; "" removes the relation |
ezobjectrelationlist | [Content!]! | object ids separated by -: "57-58-59" |
ezgmaplocation | GeoLocation | "1|#<latitude>|#<longitude>|#<address>" |
ezsrrating | Rating | (votes are not written through GraphQL) |
xrowmetadata | Metadata | the datatype's stored text form |
ngenhancedlink | EnhancedLink | the 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" |
ezoption | OptionList | "<name>|<value>|<additional price>|<value>|<additional price>..." |
ezmultioption | [OptionGroup!]! | "<name>&<group>|..." as the datatype exports it |
ezrangeoption | Range | "<name>|<start>|<stop>|<step>" |
ezmultiprice | [CurrencyPrice!]! | "<VAT type>|<VAT ex/inc>|<currency>|<value>|<type>|..." |
ezenum | [EnumValue!]! | (as the datatype's import reads it) |
ezsubtreesubscription | Boolean | "1" or "0" |
ezinisetting | String | the text form |
ezpackage | String | the text form |
ezproductcategory | String (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
| Datatype | Example | Notes |
|---|---|---|
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/richtextparses 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 mostlengthcharacters.
{ 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[];originalis the uploaded file. An unknown alias answersBAD_USER_INPUT("There is no image alias …"). variationswithoutaliaseslistsgraphql.ini ImageAliasList[](small,medium,largeby 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
widthandheightfor thewidth/heightattributes 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 }Links: ezurl → Link, ngenhancedlink → EnhancedLink
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):
- The identifier is an attribute of the class the schema shows (hidden fields and datatypes cannot be written).
- Each identifier at most once.
- File datatypes (
ezimage,ezbinaryfile,ezmedia, and the datatypes ofFileDatatypeList[]) takeupload, never a path invalue: a path would let a client import any file of the server. - Other datatypes take
valueand noupload. formatother thanRAWonly for rich text (ezxmltext).createContentneeds every required attribute;updateContentwrites only the fields given, the others keep their value;translateContentcopies the main language and overwrites the fields given.
Rich text formats:
format | value | Result |
|---|---|---|
RAW | the stored XML of the kernel (<?xml ...><section ...><paragraph>...</paragraph></section>) | stored as it is (validated by the datatype) |
TEXT | plain text; blocks separated by an empty line | one paragraph per block, whitespace in a block collapsed, special characters escaped |
HTML | simple 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
| Extension | Datatype | Type |
|---|---|---|
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
| Datatype | Empty field reads as |
|---|---|
text, numbers, dates, RichText, Image, BinaryFile, Link, Matrix, GeoLocation, Metadata, Price, OptionList, Range, EnhancedLink, single relation | null |
ezboolean, ezsubtreesubscription | false |
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).
Related pages
- GraphQL API reference · Cookbook · Maintainer guide
- The SDK types of field values: exponentialcms-datatypes; rich text: exponentialcms-richtext