JetEngine
Przykłady queries do interakcji z danymi wtyczki JetEngine firmy Crocoblock.
Pełne API (pola główne, typ JetEngineCCTEntry, filter/pagination/sort, rzutowanie pól) opisano w dokumentacji rozszerzenia JetEngine CCT.
Lista wpisów CCT
Pobierz wszystkie wpisy CCT, podając jego slug. Możesz żądać właściwości wpisu i wartości pól CCT za pomocą fieldValues lub 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")
}
}Pojedynczy wpis CCT
Pobierz jeden wpis CCT podając slug CCT i numeryczny identyfikator wpisu.
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")
}
}Pola wpisu i daty
Każdy wpis udostępnia pola niejawne (id, authorID, singleCustomPostID, daty itp.) oraz wartości pól CCT. Użyj createdDateStr / modifiedDateStr z opcjonalnym format, aby uzyskać sformatowane ciągi dat.
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")
}
}Filtrowanie wpisów CCT
Zapytania listowania i zliczania obsługują argument filter: filtruj po ids lub po search (pole, wartość, operator). Operatory to EQUALS (domyślny) i LIKE.
query JetEngineCCTEntriesWithFilter {
# Filtruj po IDs
countByIds: jetengineCCTEntryCount(cctSlug: "sample_cct", filter: {
ids: [1, 3]
})
entriesByIds: jetengineCCTEntries(cctSlug: "sample_cct", filter: {
ids: [1, 3]
}) {
id
}
# Filtruj po polu (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")
}
# Filtruj po polu (LIKE)
entriesByTextareaLike: jetengineCCTEntries(cctSlug: "sample_cct", filter: {
search: [{ field: "textarea", value: "description", operator: LIKE }]
}) {
id
textarea: fieldValue(slug: "textarea")
}
# Połącz ids + search
entriesByIdsAndSearch: jetengineCCTEntries(cctSlug: "sample_cct", filter: {
ids: [1, 4],
search: [{ field: "textarea", value: "description", operator: LIKE }]
}) {
id
textarea: fieldValue(slug: "textarea")
}
}Paginacja i sortowanie
Zapytania listowania obsługują pagination: { limit, offset } i sort: { by, order }. Sortuj według wbudowanych kluczy takich jak _ID, cct_created, cct_modified lub dowolnego slugu pola CCT.
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")
}
}Filtrowanie z paginacją
Łącz filter, pagination i sort w zapytaniach listowania; zliczanie obsługuje wyłącznie 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")
}
}