Gato GraphQL logo

Automation

Automation

Automatically execute a GraphQL Persisted Query when some event happens on the site.

Create automations directly via the WordPress editor. The automation trigger is any WordPress action hook, and the action is the execution of a GraphQL persisted query.

Automation Rule editor
Automation Rule editor

These are some examples of how we can use it:

  • Create a featured image for new posts using AI
  • Add a mandatory block to the post when published
  • Replace http with https in all image sources and links when a post is updated
  • Send an email to the admin when there's a new post
  • Send an email to the user whose comment has a new response
  • [Multisite] Translate a new post to different languages, and add the translated posts to each site
  • Execute an action on an external service (eg: automatically share new posts on Facebook)

For instance, when creating a new post, automation rule Add comments block to new post checks if the core/comments block is present and, if not, it adds it at the bottom of the post:

Automatically inserting the comments block to new 'draft' posts
Automatically inserting the comments block to new 'draft' posts

In addition, use WP-Cron to execute GraphQL queries and persisted queries, scheduling events with action hooks:

  • gatographql__execute_query
  • gatographql__execute_persisted_query

You can also react to the resolution of a GraphQL query in your application's PHP code, via the following action hooks:

  1. gatographql__executed_query:{$operationName}
  2. gatographql__executed_query