Archives: Filters

  • graphql_send_header

    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
  • graphql_is_graphql_http_request

    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 );

    Params

    • $is_graphql_http_request (bool): Whether the request is a GraphQL HTTP Request. Default false.
  • graphql_pre_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 );

    Params

    • $is_graphql_http_request (bool): Whether the request is a GraphQL HTTP Request. Default false.
  • graphql_endpoint

    Pass the route through a filter in case the endpoint /graphql should need to be changed

    apply_filters( 'graphql_endpoint', string $endpoint );

    Params

    • $endpoint (string|null): The GraphQL endpoint URL
  • 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
  • graphql_authentication_errors

    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 );

    Params

    • $authentication_errors (boolean): Whether there are authentication errors with the request
    • $request (Request): Instance of the Request
  • graphql_root_value

    Return the filtered root value

    apply_filters( 'graphql_root_value', mixed $root_value, Request $request );

    Params

    • $root_value (mixed): The root value the Schema should use to resolve with. Default null.
    • $request (Request): The Request instance
  • graphql_validation_rules

    Return the validation rules to use in the request

    apply_filters( 'graphql_validation_rules', array $validation_rules, Request $request );

    Params

    • $validation_rules (array): The validation rules to use in the request
    • $request (Request): The Request instance
  • graphql_user_can_see_query_logs

    Filter whether the logs can be seen in the request results or not

    apply_filters( 'graphql_user_can_see_query_logs', bool $can_see );

    Params

    • $can_see (bool): Whether the requestor can see the logs or not
  • graphql_post_object_mutations_allow_term_creation

    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 );

    Params

    • $allow_term_creation (bool): Whether new terms should be created during the post object mutation
    • $tax_object (WP_Taxonomy): The Taxonomy object for the term being added to the Post Object