AutomationQuery Resolution Action
Query Resolution Action
When the GraphQL server resolves a query, it triggers the following action hooks with the GraphQL response:
gatographql__executed_query:{$operationName}
(only if the GraphQL operation to execute was provided)gatographql__executed_query
The action hooks that are triggered are:
The parameters passed are:
$response
: An object of classPoP\Root\HttpFoundation\Response
, containing the GraphQL response (including content and headers)$isInternalExecution
:true
if the query was executed via the Internal GraphQL Server (eg: via classGatoGraphQL\InternalGraphQLServer\GraphQLServer
), orfalse
otherwise (eg: via the single endpoint)$operationName
: Executed GraphQL operation (for the second action hook only; on the first one, it is implicit on the hook name)$query
: Executed GraphQL query$variables
: Provided GraphQL variables
Examples
Thanks to the Internal GraphQL Server, we can react to the resolution of a GraphQL query (whether executed against the internal GraphQL Server, single endpoint, custom endpoint or persisted query), and execute another GraphQL query against the internal GraphQL Server.
An example workflow is:
- Hook into the execution of a GraphQL query, for instance by its operation name (such as
CreatePost
) - Send a notification to the admin, by executing mutation
_sendEmail
viaGatoGraphQL\InternalGraphQLServer\GraphQLServer::executeQuery
This PHP code is chaining 2 GraphQL query executions:
Next