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 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 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 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 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 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 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
}
}
Setup
Set up your development environment for CMS integration with Next.js
SSR Fetching
This section provides an overview of how to implement server-side rendering (SSR) in a Next.js application using Apollo Client to fetch and display CMS data.