플러그인 데이터 쿼리
플러그인 데이터 쿼리JetEngine

JetEngine

Crocoblock의 JetEngine 플러그인의 데이터를 다루는 쿼리 예시입니다.

전체 API(루트 필드, JetEngineCCTEntry 타입, filter/pagination/sort, 필드 캐스트)에 대해서는 JetEngine CCT 확장 기능 레퍼런스를 참고하세요.

CCT 항목 목록 조회

슬러그를 지정하여 CCT의 모든 항목을 가져옵니다. fieldValues 또는 fieldValue(slug:)를 사용하여 항목 속성과 CCT 필드 값을 요청할 수 있습니다.

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")
  }
}

단일 CCT 항목

CCT 슬러그와 항목의 숫자 ID를 지정하여 하나의 CCT 항목을 가져옵니다.

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")
  }
}

항목 필드와 날짜

각 항목은 암묵적인 필드(id, authorID, singleCustomPostID, 날짜 등)와 CCT 필드 값을 노출합니다. 포맷된 날짜 문자열을 가져오려면 createdDateStr / modifiedDateStr에 선택적 format을 지정하세요.

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")
  }
}

CCT 항목 필터링

목록 조회와 카운트는 filter 인수를 지원합니다. ids 또는 필드·값·연산자를 지정한 search로 필터링할 수 있습니다. 연산자에는 EQUALS(기본값)와 LIKE가 있습니다.

query JetEngineCCTEntriesWithFilter {
  # Filter by IDs
  countByIds: jetengineCCTEntryCount(cctSlug: "sample_cct", filter: { 
    ids: [1, 3] 
  })
  entriesByIds: jetengineCCTEntries(cctSlug: "sample_cct", filter: { 
    ids: [1, 3] 
  }) {
    id
  }
 
  # Filter by 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 by field (LIKE)
  entriesByTextareaLike: jetengineCCTEntries(cctSlug: "sample_cct", filter: {
    search: [{ field: "textarea", value: "description", operator: LIKE }] 
  }) {
    id
    textarea: fieldValue(slug: "textarea")
  }
 
  # Combine ids + search
  entriesByIdsAndSearch: jetengineCCTEntries(cctSlug: "sample_cct", filter: {
    ids: [1, 4],
    search: [{ field: "textarea", value: "description", operator: LIKE }] 
  }) {
    id
    textarea: fieldValue(slug: "textarea")
  }
}

페이지네이션과 정렬

목록 쿼리는 pagination: { limit, offset }sort: { by, order }를 지원합니다. _ID, cct_created, cct_modified 등의 내장 키 또는 임의의 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")
  }
}

필터와 페이지네이션 조합

목록 쿼리에서 filter, pagination, sort를 조합할 수 있습니다. 카운트는 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")
  }
}