쿼리 라이브러리
쿼리 라이브러리모든 게시물에서 이전 도메인을 새 도메인으로 교체하기

모든 게시물에서 이전 도메인을 새 도메인으로 교체하기

이 쿼리는 먼저 콘텐츠에 "https://my-old-domain.com"이 포함된 모든 게시물을 필터링한 후, 해당 문자열을 "https://my-new-domain.com"으로 교체합니다.

이 쿼리를 실행하려면 엔드포인트에서 중첩 Mutation이 활성화되어 있어야 합니다.

mutation ReplaceOldWithNewDomainInPosts(
  $oldDomain: String!,
  $newDomain: String!
) {
  posts(
    filter: {
      search: $oldDomain
    },
    pagination: {
      limit: -1
    }
  ) {
    id
    rawContent
    adaptedRawContent: _strReplace(
      search: $oldDomain
      replaceWith: $newDomain
      in: $__rawContent
    )
    update(input: {
      contentAs: { html: $__adaptedRawContent }
    }) {
      status
      errors {
        __typename
        ...on ErrorPayload {
          message
        }
      }
      post {
        id
        rawContent
      }
    }
  }
}