Filter the headers
apply_filters( 'graphql_send_header', string $key_value, string $key, string $value );
Params
- $key_value (string): The header key value pair
- $key (string): The header key
- $value (string): The sanitized header value
Filter the headers
apply_filters( 'graphql_send_header', string $key_value, string $key, string $value );
Filter whether the request is a GraphQL HTTP Request. Default is false, as the majority of WordPress requests are NOT GraphQL requests (at least today that’s true ????).
The request has to “prove” that it is indeed an HTTP request via HTTP for this to be true.
Different servers _might_ have different needs to determine whether a request is a GraphQL request.
apply_filters( 'graphql_is_graphql_http_request', bool $is_graphql_http_request );
Filter whether the request is a GraphQL HTTP Request. Default is null, as the majority of WordPress requests are NOT GraphQL requests (at least today that’s true ????).
If this filter returns anything other than null, the function will return now and skip the default checks.
apply_filters( 'graphql_pre_is_graphql_http_request', bool $is_graphql_http_request );
Pass the route through a filter in case the endpoint /graphql
should need to be changed
apply_filters( 'graphql_endpoint', string $endpoint );
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 );
If false, there are no authentication errors. If true, execution of the GraphQL request will be prevented and an error will be thrown.
apply_filters( 'graphql_authentication_errors', boolean $authentication_errors, Request $request );
Return the filtered root value
apply_filters( 'graphql_root_value', mixed $root_value, Request $request );
Return the validation rules to use in the request
apply_filters( 'graphql_validation_rules', array $validation_rules, Request $request );
Filter whether the logs can be seen in the request results or not
apply_filters( 'graphql_user_can_see_query_logs', bool $can_see );
Filter whether to allow terms to be created during a post mutation.
If a post mutation includes term input for a term that does not already exist, this will allow terms to be created in order to connect the term to the post object, but if filtered to false, this will prevent the term that doesn’t already exist from being created during the mutation of the post.
apply_filters( 'graphql_post_object_mutations_allow_term_creation', bool $allow_term_creation, WP_Taxonomy $tax_object );