JetEngine
Contoh query untuk berinteraksi dengan data dari plugin JetEngine milik Crocoblock.
Untuk API lengkap (root fields, tipe JetEngineCCTEntry, filter/pagination/sort, field casts), lihat referensi ekstensi JetEngine CCT.
Daftar entri CCT
Query semua entri untuk sebuah CCT dengan memberikan slug-nya. Anda dapat meminta properti entri dan nilai field CCT melalui fieldValues atau fieldValue(slug:).
query JetEngineCCTEntries($cctSlug: String!) {
jetengineCCTEntryCount(cctSlug: $cctSlug)
jetengineCCTEntries(cctSlug: $cctSlug) {
id
cctSlug
status
authorID
author {
id
name
}
singleCustomPostID
singleCustomPost {
id
title
customPostType
}
createdDate
createdDateStr
modifiedDate
modifiedDateStr
fieldValues
label_text: fieldValue(slug: "label_text")
textarea: fieldValue(slug: "textarea")
number: fieldValue(slug: "number")
switcher: fieldValue(slug: "switcher")
gallery: fieldValue(slug: "gallery")
}
}Entri CCT tunggal
Ambil satu entri CCT berdasarkan slug CCT dan ID numerik entri tersebut.
query JetEngineCCTEntry($cctSlug: String!, $id: ID!) {
jetengineCCTEntry(cctSlug: $cctSlug, by: { id: $id }) {
id
uniqueID
cctSlug
status
authorID
author {
id
name
}
singleCustomPostID
singleCustomPost {
id
title
customPostType
}
createdDate
createdDateStr
modifiedDate
modifiedDateStr
fieldValues
label_text: fieldValue(slug: "label_text")
textarea: fieldValue(slug: "textarea")
repeater: fieldValue(slug: "repeater")
}
}Field entri dan tanggal
Setiap entri mengekspos field implisit (id, authorID, singleCustomPostID, tanggal, dll.) dan nilai field CCT. Gunakan createdDateStr / modifiedDateStr dengan format opsional untuk string tanggal yang diformat.
query JetEngineCCTEntryFields {
jetengineCCTEntry(cctSlug: "sample_cct", by: { id: 1 }) {
id
uniqueID
cctSlug
status
singleCustomPostID
singleCustomPost {
id
title
customPostType
}
authorID
author {
id
name
}
createdDate
createdDateStr
formattedCreatedDateStr: createdDateStr(format: "d/m/Y")
modifiedDate
modifiedDateStr
formattedModifiedDateStr: modifiedDateStr(format: "d/m/Y")
fieldValues
label_text: fieldValue(slug: "label_text")
number: fieldValue(slug: "number")
}
}Filter entri CCT
Daftar dan penghitungan mendukung argumen filter: filter berdasarkan ids atau berdasarkan search (field, nilai, operator). Operator mencakup EQUALS (default) dan LIKE.
query JetEngineCCTEntriesWithFilter {
# Filter berdasarkan IDs
countByIds: jetengineCCTEntryCount(cctSlug: "sample_cct", filter: {
ids: [1, 3]
})
entriesByIds: jetengineCCTEntries(cctSlug: "sample_cct", filter: {
ids: [1, 3]
}) {
id
}
# Filter berdasarkan field (EQUALS)
entriesByAuthor: jetengineCCTEntries(cctSlug: "sample_cct", filter: {
search: [{ field: "cct_author_id", value: 1, operator: EQUALS }]
}) {
id
authorID
}
entriesByLabel: jetengineCCTEntries(cctSlug: "sample_cct", filter: {
search: [{ field: "label_text", value: "Some label" }]
}) {
id
label_text: fieldValue(slug: "label_text")
}
# Filter berdasarkan field (LIKE)
entriesByTextareaLike: jetengineCCTEntries(cctSlug: "sample_cct", filter: {
search: [{ field: "textarea", value: "description", operator: LIKE }]
}) {
id
textarea: fieldValue(slug: "textarea")
}
# Gabungkan ids + search
entriesByIdsAndSearch: jetengineCCTEntries(cctSlug: "sample_cct", filter: {
ids: [1, 4],
search: [{ field: "textarea", value: "description", operator: LIKE }]
}) {
id
textarea: fieldValue(slug: "textarea")
}
}Pagination dan sort
Query daftar menerima pagination: { limit, offset } dan sort: { by, order }. Urutkan berdasarkan kunci bawaan seperti _ID, cct_created, cct_modified, atau berdasarkan slug field CCT apa pun.
query JetEngineCCTEntriesWithPagination {
entriesWithLimit: jetengineCCTEntries(cctSlug: "sample_cct", pagination: { limit: 2 }) {
id
createdDate
textarea: fieldValue(slug: "textarea")
}
entriesPage2: jetengineCCTEntries(cctSlug: "sample_cct", pagination: { limit: 1, offset: 1 }) {
id
createdDate
textarea: fieldValue(slug: "textarea")
}
entriesSortByCreatedDesc: jetengineCCTEntries(cctSlug: "sample_cct", sort: { by: "cct_created", order: DESC }) {
id
createdDate
textarea: fieldValue(slug: "textarea")
}
entriesSortByIdAsc: jetengineCCTEntries(cctSlug: "sample_cct", sort: { by: "_ID", order: ASC }) {
id
textarea: fieldValue(slug: "textarea")
}
}Filter dengan pagination
Gabungkan filter, pagination, dan sort dalam query daftar; penghitungan hanya menerima filter.
query JetEngineCCTEntriesFilterAndPagination {
jetengineCCTEntryCount(
cctSlug: "sample_cct"
filter: { search: [{ field: "textarea", value: "description", operator: LIKE }] }
)
jetengineCCTEntries(
cctSlug: "sample_cct"
filter: { search: [{ field: "textarea", value: "description", operator: LIKE }] }
pagination: { limit: 10, offset: 0 }
sort: { by: "cct_created", order: DESC }
) {
id
textarea: fieldValue(slug: "textarea")
}
}