Queryライブラリ
Queryライブラリすべての投稿で古いドメインを新しいドメインに置き換える

すべての投稿で古いドメインを新しいドメインに置き換える

このクエリは、まずコンテンツに "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
      }
    }
  }
}