Schema tutorialLesson 15: Sending a daily summary of activity
Lesson 15: Sending a daily summary of activity
We can integrate Gato GraphQL with WP-Cron, as to automate the execution GraphQL queries that perform admin tasks, with some time interval. (The Automation extension is required.)
In this tutorial lesson, we set-up WP-Cron to, every 24 hs, execute a GraphQL query that retrieves the number of new comments added to the site, and sends these stats to the desired email account.
We must schedule the WP-Cron event to execute the Gato GraphQL hook gatographql__execute_persisted_query, passing along the email to send the email to as argument, and the recurrence (daily).
The 4th argument passed to the WP-Cron event is the ID (as an int) or username (as a string) of the user that must be logged-in when executing the GraphQL query.
(In this case, value 1 is the ID of the admin user, and could have provided username "admin" too.)
Passing this argument is typically needed when executing mutations, as most of these require a user (with the proper capabilities) to be logged-in.