Blog

⭐️ Rilasciata v3.0 con supporto per WordPress 6.6 e bulk mutations

Leonardo Losoviz
Di Leonardo Losoviz ·

Gato GraphQL v3.0 è stata rilasciata, contenente nuove funzionalità e alcune breaking changes. Consulta le note di release su GitHub per l'elenco completo dei cambiamenti.

Di seguito gli aggiornamenti più importanti.

Aggiunta compatibilità con WordPress 6.6

Gato GraphQL 3.0 ha ricompilato tutti i suoi blocchi, per renderli compatibili con WordPress 6.6. (Per tutte le versioni precedenti, i blocchi genereranno un errore JS.)

Aggiunti campi di bulk mutation (per tutte le mutations dello schema)

Gato GraphQL 3.0 aggiunge campi di bulk mutation per tutte le mutations dello schema, permettendoci di mutare più risorse.

Ad esempio, la mutation createPosts (la mutation su una singola risorsa è createPost) creerà più articoli:

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
    }
  }
}

Le bulk mutations aprono nuove possibilità per gestire il nostro sito WordPress. Ad esempio, la seguente query GraphQL utilizza createPosts (e Multiple Query Execution, fornito da Gato GraphQL PRO) per duplicare gli articoli:

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
    }
  }
}

L'elenco dei campi di bulk mutation aggiunti è il seguente:

  • 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: Richiede almeno WordPress v6.0

Per supportare WordPress v6.6, i blocchi del plugin hanno dovuto essere ricompilati prendendo come riferimento WordPress v6.0+.

Pertanto, a partire da v3.0, Gato GraphQL richiede almeno WordPress v6.0.

Breaking change: Il blocco di configurazione dello schema "Payload Types for Mutations" potrebbe richiedere una riconfigurazione

Al blocco di configurazione dello schema "Payload Types for Mutations" è stato aggiunto un nuovo valore di opzione: "Do not use payload types for mutations (i.e. return the mutated entity)". Per questo motivo, la sua struttura dati interna è cambiata.

Se hai creato una configurazione di schema con l'opzione "Do not use payload types for mutations (i.e. return the mutated entity)" selezionata, dopo l'aggiornamento a v3.0 questo valore di selezione andrà perso. Devi modificare la configurazione dello schema, selezionare di nuovo questa opzione e salvare.


Iscriviti alla nostra newsletter

Resta aggiornato su tutte le novità di Gato GraphQL.