쿼리 라이브러리게시물에서 블록 제거하기
게시물에서 블록 제거하기
이 쿼리는 지정한 유형의 블록(예: mycompany:black-friday-campaign-video)을 모든 게시물에서 제거합니다.
이 쿼리를 실행하려면 엔드포인트에서 중첩 뮤테이션이 활성화되어 있어야 합니다.
query CreateVars(
$removeBlockType: String!
) {
regex: _sprintf(
string: "#(<!-- %1$s -->[\\s\\S]+<!-- /%1$s -->)#",
values: [$removeBlockType]
)
@export(as: "regex")
@remove
search: _sprintf(
string: "\"<!-- /%1$s -->\"",
values: [$removeBlockType]
)
@export(as: "search")
@remove
}
mutation RemoveBlockFromPosts
@depends(on: "CreateVars")
{
posts(filter: { search: $search } ) {
id
rawContent
adaptedRawContent: _strRegexReplace(
in: $__rawContent,
searchRegex: $regex,
replaceWith: ""
)
update(input: {
contentAs: { html: $__adaptedRawContent },
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
post {
id
rawContent
}
}
}
}