Queries Kütüphanesi
Queries KütüphanesiTüm yazılarda eski bir yazı slug'ını yeni bir yazı slug'ı ile değiştir

Tüm yazılarda eski bir yazı slug'ını yeni bir yazı slug'ı ile değiştir

Bir yazının slug'ını değiştirdikten sonra, tüm içeriği yeni URL'ye işaret edecek şekilde dönüştürmek için bu query'yi çalıştırın.

Bu query, endpoint'in İç içe Mutation'ları etkinleştirmiş olmasını gerektirir.

query ExportData(
  $oldPostSlug: String!
  $newPostSlug: String!
) {
  siteURL: optionValue(name: "siteurl")
 
  oldPostURL: _strAppend(
    after: $__siteURL,
    append: $oldPostSlug
  ) @export(as: "oldPostURL")
 
  newPostURL: _strAppend(
    after: $__siteURL,
    append: $newPostSlug
  ) @export(as: "newPostURL")
}
 
mutation ReplaceOldWithNewSlugInPosts
  @depends(on: "ExportData")
{
  posts(
    filter: {
      search: $oldPostURL
    },
    pagination: {
      limit: -1
    }
  ) {
    id
    rawContent
    adaptedRawContent: _strReplace(
      search: $oldPostURL
      replaceWith: $newPostURL
      in: $__rawContent
    )
    update(input: {
      contentAs: { html: $__adaptedRawContent }
    }) {
      status
      errors {
        __typename
        ...on ErrorPayload {
          message
        }
      }
      post {
        id
        rawContent
      }
    }
  }
}