graphql_request_results

Filter the $response of the GraphQL execution. This allows for the response to be filtered before it’s returned, allowing granular control over the response at the latest point.

POSSIBLE USAGE EXAMPLES: This could be used to ensure that certain fields never make it to the response if they match certain criteria, etc. For example, this filter could be used to check if a current user is allowed to see certain things, and if they are not, the $response could be filtered to remove the data they should not be allowed to see.

Or, perhaps some systems want the response to always include some additional piece of data in every response, regardless of the request that was sent to it, this could allow for that to be hooked in and included in the $response.

apply_filters( 'graphql_request_results', array $response, WPGraphQL\WPSchema $schema, string $operation, string $query, array $variables, Request $request );

Params

  • $response (array): The response for your GraphQL query
  • $schema (WPGraphQL\WPSchema): The schema object for the root query
  • $operation (string): The name of the operation
  • $query (string): The query that GraphQL executed
  • $variables (array|null): Variables to passed to your GraphQL request
  • $request (Request): Instance of the Request