Queries for CMS
This section provides an overview of how to query and mutate data in the Erxes CMS using Apollo Client in a Next.js application.
You need these queries to get started with your CMS integration. Keep in mind if you don't need some of the fields, you can remove them from the queries to optimize performance.
Query for CMS Posts
query CmsPosts($clientPortalId: String, $featured: Boolean, $type: String, $categoryId: String, $searchValue: String, $status: PostStatus, $page: Int, $perPage: Int, $tagIds: [String], $sortField: String, $sortDirection: String, $language: String) {
cmsPosts(clientPortalId: $clientPortalId, featured: $featured, type: $type, categoryId: $categoryId, searchValue: $searchValue, status: $status, page: $page, perPage: $perPage, tagIds: $tagIds, sortField: $sortField, sortDirection: $sortDirection, language: $language) {
_id
attachments {
name
size
url
type
}
type
title
thumbnail {
url
type
name
}
updatedAt
tags {
_id
name
}
status
slug
images {
url
type
size
name
}
excerpt
customPostType {
_id
label
code
}
customFieldsData
customFieldsMap
createdAt
content
categoryIds
author {
... on User {
_id
email
}
... on ClientPortalUser {
fullName
firstName
lastName
}
}
}
}
Query for CMS Post details
query CmsPost($language: String, $slug: String, $id: String) {
cmsPost(language: $language, slug: $slug, _id: $id) {
_id
attachments {
name
size
url
type
}
type
title
thumbnail {
url
type
name
}
updatedAt
tags {
_id
name
}
status
slug
images {
url
type
size
name
}
excerpt
customPostType {
_id
label
code
}
customFieldsData
customFieldsMap
createdAt
content
categoryIds
author {
... on User {
_id
email
}
... on ClientPortalUser {
fullName
firstName
lastName
}
}
}
}
Query for CMS Pages
query CmsPages($searchValue: String, $perPage: Int, $page: Int, $clientPortalId: String) {
cmsPages(searchValue: $searchValue, perPage: $perPage, page: $page, clientPortalId: $clientPortalId) {
_id
clientPortalId
name
description
coverImage
type
slug
content
createdUserId
createdUser {
_id
username
email
details {
lastName
fullName
firstName
}
}
createdAt
updatedAt
customFieldsData
customFieldsMap
}
}
Query for CMS Page details
query CmsPage($language: String, $slug: String, $id: String) {
cmsPage(language: $language, slug: $slug, _id: $id) {
_id
clientPortalId
name
description
coverImage
type
slug
content
createdUserId
createdUser {
_id
username
email
details {
lastName
fullName
firstName
}
}
createdAt
updatedAt
customFieldsData
customFieldsMap
}
}
Query for CMS Categories
query CmsCategories($clientPortalId: String, $searchValue: String, $status: CategoryStatus, $page: Int, $perPage: Int, $sortField: String, $sortDirection: String) {
cmsCategories(clientPortalId: $clientPortalId, searchValue: $searchValue, status: $status, page: $page, perPage: $perPage, sortField: $sortField, sortDirection: $sortDirection) {
_id
clientPortalId
name
slug
description
parentId
status
parent {
_id
clientPortalId
name
slug
description
parentId
status
createdAt
updatedAt
customFieldsData
customFieldsMap
}
createdAt
updatedAt
customFieldsData
customFieldsMap
}
}
Query for CMS Category details
query CmsCategory($id: String, $slug: String) {
cmsCategory(_id: $id, slug: $slug) {
_id
clientPortalId
name
slug
description
parentId
status
parent {
_id
clientPortalId
name
slug
description
parentId
status
createdAt
updatedAt
customFieldsData
customFieldsMap
}
createdAt
updatedAt
customFieldsData
customFieldsMap
}
}
Query for CMS Menus
query CmsMenuList($clientPortalId: String, $kind: String) {
cmsMenuList(clientPortalId: $clientPortalId, kind: $kind) {
_id
parentId
parent {
_id
parentId
clientPortalId
label
contentType
contentTypeID
kind
icon
url
order
target
}
clientPortalId
label
contentType
contentTypeID
kind
icon
url
order
target
}
}
Query for CMS Menu details
query CmsMenu($id: String!) {
cmsMenu(_id: $id) {
_id
parentId
parent {
_id
parentId
clientPortalId
label
contentType
contentTypeID
kind
icon
url
order
target
}
clientPortalId
label
contentType
contentTypeID
kind
icon
url
order
target
}
}
Go to next section to learn how to use these queries.