GraphQL Files

The GraphQL Files Schema provides a robust API for managing file uploads and their associated metadata within the CMS. This documentation outlines the available types, queries, mutations, and input objects for developers to interact with file resources.

Table of Contents:

File

The File type represents a stored file with its associated metadata and relationships.

Field Type Description
id ID! Unique ID of the stored file
mime String Mime type of the stored file
lang String ISO language code, e.g. 'en', 'en-GB' or empty for default language
name String Descriptive name of the file
description JSON Description of the file in different languages with ISO language code as key
transcription JSON Transcription of the file content in different languages with ISO language code as key
path String! Relative path to the stored file
previews JSON! Preview images of the stored file if any
editor String! Name of the last user who added, updated or deleted the file
created_at String! Date/time value when the file was created
updated_at String! Date/time value when the file was last modified
deleted_at String Date/time value when the file was deleted or NULL if it's available
byelements [Element!]! List of elements using the file
bypages [Page!]! List of pages using the file
byversions [Version!]! List of versions using the file
latest Version Latest version of the file
versions [Version!]! List of versioned data for the file

Queries

FileFilter

Input type for filtering file queries.

Field Type Description
id [ID!] IDs of the stored files
mime String Mime type of the stored files
lang String ISO language code, e.g. 'en', 'en-GB' or empty for default language
name String Descriptive name of the stored files
editor String Name of the last user who added, updated or deleted the files
any String Search for this string in any text field

Example:

query {
  files(filter: { lang: "en", name: "report" }) {
    id
    name
  }
}

file(id: ID!)

Get a single file item by its unique ID.

Arguments:

Argument Type Description
id ID! The unique ID of the file to retrieve.

Example:

query {
  file(id: "123") {
    id
    name
    path
    mime
  }
}

files(filter: FileFilter, sort: _, publish: Publish)

Get a list of available files, with options for filtering, sorting, and publishing status.

Arguments:

Argument Type Description
filter FileFilter Filters the list of files based on various criteria.
sort _ Specifies the sorting order. Default sort is by id in descending order.
publish Publish Filters files by their publishing status (e.g., all, published).

Example:

query {
  files(filter: { mime: "image/jpeg" }, sort: "name", publish: all) {
    id
    name
    mime
    lang
    editor
  }
}

Mutations

FileInput

Input type for creating or updating file data.

Field Type Description
lang String ISO language code, e.g. 'en', 'en-GB' or empty for default language
name String Descriptive name of the stored file
path String URL or relative path within the storage of the file
previews JSON Preview images of the stored file if any
description JSON Description of the file in different languages with ISO language code as key
transcription JSON Transcription of the file content in different languages with ISO language code as key

Example:

mutation AddNewFile {
  addFile(
    input: {
      lang: "en"
      name: "New Company Brochure"
      description: "{\"en\": \"Our latest company brochure.\"}"
    }
    file: "<UPLOAD_FILE_DATA>"
  ) {
    id
    name
  }
}

addFile(input: FileInput, file: Upload, preview: Upload)

Adds a new file upload, optionally with a preview image and a description.

Arguments:

Argument Type Description
input FileInput The input data for the new file, including name, language, and description.
file Upload The actual file to be uploaded.
preview Upload An optional preview image for the file.

Example:

mutation AddNewFile($file: Upload!, $preview: Upload!) {
  addFile(input: { name: "My Document", lang: "en" }, file: $file, preview: $preview) {
    id
    name
    path
  }
}

saveFile(id: ID!, input: FileInput!, file: Upload, preview: RemoveableUpload)

Updates an existing file identified by its ID.

Arguments:

Argument Type Description
id ID! The unique ID of the file to update.
input FileInput! The updated input data for the file.
file Upload A new file to replace the existing one, if provided.
preview RemoveableUpload A new preview image, or true to remove the existing preview, or false to keep it.

Example:

mutation UpdateFile($fileId: ID!, $newFile: Upload, $newPreview: RemoveableUpload) {
  saveFile(
    id: $fileId
    input: { name: "Updated Document Name" }
    file: $newFile
    preview: $newPreview
  ) {
    id
    name
    updated_at
  }
}

dropFile(id: [ID!]!)

Deletes one or more existing files. This performs a soft delete, marking files as deleted but retaining them in the database.

Arguments:

Argument Type Description
id [ID!]! An array of unique IDs of the files to delete.

Example:

mutation DeleteFiles {
  dropFile(id: ["123", "456"]) {
    id
    name
    deleted_at
  }
}

keepFile(id: [ID!]!)

Restores one or more previously soft-deleted files.

Arguments:

Argument Type Description
id [ID!]! An array of unique IDs of the files to restore.

Example:

mutation RestoreFiles {
  keepFile(id: ["123"]) {
    id
    name
    deleted_at
  }
}

purgeFile(id: [ID!]!)

Permanently purges one or more files from the database and storage. This action cannot be undone.

Arguments:

Argument Type Description
id [ID!]! An array of unique IDs of the files to purge.

Example:

mutation PurgeFiles {
  purgeFile(id: ["789"]) {
    id
  }
}

pubFile(id: [ID!]!, at: DateTime)

Publishes one or more files at a specific date and time.

Arguments:

Argument Type Description
id [ID!]! An array of unique IDs of the files to publish.
at DateTime The date and time at which the files should be published.
Example:
mutation PublishFiles {
  pubFile(id: ["101"], at: "2025-09-01T10:00:00Z") {
    id
    name
  }
}