บล็อก

⭐️ เปิดตัว v3.0 พร้อมรองรับ WordPress 6.6 และ bulk mutations

Leonardo Losoviz
โดย Leonardo Losoviz ·

Gato GraphQL v3.0 ได้เปิดตัวแล้ว พร้อมฟีเจอร์ใหม่และการเปลี่ยนแปลงที่ส่งผลกระทบต่อความเข้ากันได้สองรายการ ดูรายการการเปลี่ยนแปลงทั้งหมดได้ที่ release notes บน GitHub

ด้านล่างนี้คืออัปเดตที่สำคัญที่สุด

เพิ่มความเข้ากันได้กับ WordPress 6.6

Gato GraphQL 3.0 ได้คอมไพล์บล็อกทั้งหมดใหม่ เพื่อให้เข้ากันได้กับ WordPress 6.6 (สำหรับเวอร์ชันก่อนหน้าทั้งหมด บล็อกจะเกิด JS error)

เพิ่มฟิลด์ bulk mutation (สำหรับ mutations ทั้งหมดใน schema)

Gato GraphQL 3.0 เพิ่มฟิลด์ "bulk" mutation สำหรับ mutations ทั้งหมดใน schema ช่วยให้สามารถ mutate ทรัพยากรหลายรายการพร้อมกันได้

ตัวอย่างเช่น mutation createPosts (mutation สำหรับทรัพยากรเดียวคือ createPost) จะสร้างโพสต์หลายรายการ:

mutation CreatePosts {
  createPosts(inputs: [
    {
      title: "First post"
      contentAs: {
        html: "This is the content for the first post"
      }
    },
    {
      title: "Second post"
      contentAs: {
        html: "Here is another content, for another post"
      }
      excerpt: "The cup is within reach"
    },
    {
      title: "Third post"
      contentAs: {
        html: "This is yet another piece of content"
      },
      authorBy: {
        id: 1
      },
      status: draft
    }
  ]) {
    status
    errors {
      __typename
      ...on ErrorPayload {
        message
      }
    }
    post {
      id
      title
      content
      excerpt
      author {
        name
      }
      status
    }
  }
}

Bulk mutations เปิดโอกาสใหม่ในการจัดการเว็บไซต์ WordPress ตัวอย่างเช่น GraphQL query ต่อไปนี้ใช้ createPosts (และ Multiple Query Execution ที่ให้บริการโดย Gato GraphQL PRO) เพื่อทำซ้ำโพสต์:

query ExportPostData
{
  postsToDuplicate: posts {
    rawTitle
    rawContent
    rawExcerpt
    postInput: _echo(value: {
      title: $__rawTitle
      contentAs: {
        html: $__rawContent
      },
      excerpt: $__rawExcerpt
    })
      @export(as: "postInputs", type: LIST)
      @remove
  }
}
 
mutation CreatePosts
  @depends(on: "ExportPostData")
{
  createPosts(inputs: $postInputs) {
    status
    errors {
      __typename
      ...on ErrorPayload {
        message
      }
    }
    post {
      id
      title
      content
      excerpt
    }
  }
}

รายการฟิลด์ bulk mutation ที่เพิ่มเข้ามามีดังนี้:

  • Root.addCommentToCustomPosts
  • Root.createCustomPosts
  • Root.createMediaItems
  • Root.createPages
  • Root.createPosts
  • Root.removeFeaturedImageFromCustomPosts
  • Root.replyComments
  • Root.setCategoriesOnPosts
  • Root.setFeaturedImageOnCustomPosts
  • Root.setTagsOnPosts
  • Root.updateCustomPosts
  • Root.updatePages
  • Root.updatePosts
  • Comment.replyWithComments
  • CustomPost.addComments

Breaking change: ต้องใช้ WordPress v6.0 ขึ้นไป

เพื่อรองรับ WordPress v6.6 บล็อกต่างๆ ในปลั๊กอินต้องถูกคอมไพล์ใหม่โดยกำหนดเป้าหมายเป็น WordPress v6.0+

ดังนั้น ตั้งแต่ v3.0 เป็นต้นไป Gato GraphQL ต้องการ WordPress v6.0 เป็นอย่างน้อย

Breaking change: บล็อกการกำหนดค่า schema "Payload Types for Mutations" อาจต้องกำหนดค่าใหม่

บล็อกการกำหนดค่า schema "Payload Types for Mutations" ได้รับการเพิ่มค่าตัวเลือกใหม่: "Do not use payload types for mutations (i.e. return the mutated entity)" ด้วยเหตุนี้ โครงสร้างข้อมูลภายในจึงมีการเปลี่ยนแปลง

หากคุณได้สร้างการกำหนดค่า schema โดยเลือกตัวเลือก "Do not use payload types for mutations (i.e. return the mutated entity)" ไว้ หลังจากอัปเกรดเป็น v3.0 ค่าที่เลือกไว้นั้นจะหายไป คุณต้องแก้ไขการกำหนดค่า schema เลือกตัวเลือกนี้อีกครั้ง แล้วบันทึก


สมัครรับจดหมายข่าวของเรา

ติดตามการอัปเดตทั้งหมดของ Gato GraphQL