Queries KütüphanesiBir Bricks gönderisini kopyala
Bir Bricks gönderisini kopyala
Bu query, bir Bricks özel gönderisini (başlık, içerik, özet, yazar, öne çıkan görsel ve meta veriler dahil) kopyalar ve kopyalanan özel gönderi için Bricks öğe kimliklerini yeniden oluşturur.
Bu query, Bricks uzantısının etkinleştirilmesini gerektirir.
Query aşağıdaki değişkenleri gerektirir:
customPostId: Kopyalanacak Bricks özel gönderisinin kimliği.
query InitializeDynamicVariables
@configureWarningsOnExportingDuplicateVariable(enabled: false)
{
authorID: _echo(value: null)
@export(as: "authorID")
@remove
featuredImageID: _echo(value: null)
@export(as: "featuredImageID")
@remove
meta: _echo(value: {})
@export(as: "meta")
@remove
bricksIsEnabledForCustomPostType: _echo(value: false)
@export(as: "bricksIsEnabledForCustomPostType")
@remove
}
query GetBricksCustomPostAndExportData($customPostId: ID!)
@depends(on: "InitializeDynamicVariables")
{
customPost(by: { id: $customPostId }, status: any) {
bricksIsEnabledForCustomPostType
@export(as: "bricksIsEnabledForCustomPostType")
# Fields not to be duplicated
id
slug
date
status
# Fields to be duplicated
author {
id @export(as: "authorID")
}
customPostType @export(as: "customPostType")
rawContent @export(as: "rawContent")
rawExcerpt @export(as: "excerpt")
featuredImage {
id @export(as: "featuredImageID")
}
rawTitle @export(as: "title")
metaKeys(filter: { exclude: ["_thumbnail_id", "_edit_last"] })
meta(keys: $__metaKeys)
@export(as: "meta")
}
}
mutation DuplicateBricksCustomPost
@depends(on: "GetBricksCustomPostAndExportData")
@include(if: $bricksIsEnabledForCustomPostType)
{
createCustomPost(input: {
status: draft,
customPostType: $customPostType,
authorBy: {
id: $authorID
},
contentAs: {
html: $rawContent
},
excerpt: $excerpt
featuredImageBy: {
id: $featuredImageID
},
title: $title,
meta: $meta
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
customPost {
# Fields not to be duplicated
id @export(as: "newCustomPostId")
slug
date
status
# Fields to be duplicated
customPostType
author {
id
}
rawContent
excerpt
featuredImage {
id
}
title
metaKeys(filter: { exclude: ["_thumbnail_id", "_edit_last"] })
meta(keys: $__metaKeys)
}
}
}
mutation RegenerateDuplicatedCustomPostBricksData
@depends(on: "DuplicateBricksCustomPost")
@include(if: $bricksIsEnabledForCustomPostType)
{
bricksRegenerateCustomPostElementIDSet(input: {
customPostID: $newCustomPostId
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
}
}