Filters

WordPress provides an API called "filters" which allow functions to modify data of other functions. WPGraphQL applies many filters throughout its codebase allowing developers to customize the Schema and other parts of the GraphQL server. Below are the filters provided by WPGraphQL that are available for developers to hook into.

    graphql_cursor_ordering_field

    Filters the field used for ordering connection queries when cursors are used for pagination

    graphql_html_entity_decoding_enabled

    Given a string, and optional context, this decodes html entities if html_entity_decode is enabled

    graphql_wp_union_type_config

    Filter the config of WPUnionType

    graphql_union_possible_types

    Filter the possible_types to allow systems to add to the possible resolveTypes.

    graphql_union_resolve_type

    Filter the resolve type method for all unions

    graphql_schema_config

    Set the $filterable_config as the $config that was passed to the WPSchema when instantiated

    graphql_custom_scalar_config

    Filter WPScalar config

    graphql_object_fields

    Filter all object fields, passing the $typename as a param. This is useful when several different types need to be easily filtered at once. . .for example, if ALL types with a field of a certain name needed to be adjusted, or something to that tune.

    graphql_object_type_interfaces

    Filters the interfaces applied to an object type

    graphql_wp_object_type_config

    Filter the config of WPObjectType

    graphql_interface_fields

    Filter all object fields, passing the $typename as a param.

    graphql_wp_interface_type_config

    Filter the config of WPInterfaceType

    graphql_interface_resolve_type

    Filter the resolve type method for all interfaces

    graphql_input_fields

    Filter all object fields, passing the $typename as a param.

    graphql_request_data

    Allow the request data to be filtered. Previously this filter was only applied to non-HTTP requests. Since 0.2.0, we will apply it to all requests.

    graphql_enum_values

    Pass the enum values through a filter

    graphql_user_insert_post_args

    Filters the mappings for input to arguments

    graphql_user_mutation_input_fields

    Filters all of the fields available for input

    graphql_map_input_fields_to_wp_user_query

    Filter the input fields. This allows plugins/themes to hook in and alter what $args should be allowed to be passed from a GraphQL Query to the WP_User_Query.

    graphql_tracing_response

    Filter the trace

    graphql_user_can_see_trace_data

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

    graphql_term_object_insert_term_args

    Filter the $insert_args

    graphql_map_input_fields_to_get_terms

    Filter the input fields. This allows plugins/themes to hook in and alter what $args should be allowed to be passed from a GraphQL Query to the get_terms query.

    graphql_term_object_connection_query_args

    Filter the query_args that should be applied to the query. This filter is applied AFTER the input args from the GraphQL Query have been applied and has the potential to override the GraphQL Query Input Args.

    graphql_settings_sections

    Filter the settings sections

    graphql_setting_field_config

    Filter the setting field config

    graphql_response_status_code

    Filter the $status_code before setting the headers

    graphql_response_headers_to_send

    Filter the $headers to send

    graphql_send_nocache_headers

    Filter to determine if nocache headers are sent on authenticated requests.

    graphql_access_control_allow_headers

    Filtered list of access control headers

    graphql_send_header

    Filter the headers

    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 ????).

    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 ????).

    graphql_endpoint

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

    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.

    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.

    graphql_root_value

    Return the filtered root value

    graphql_validation_rules

    Return the validation rules to use in the request

    graphql_user_can_see_query_logs

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

    graphql_post_object_mutations_allow_term_creation

    Filter whether to allow terms to be created during a post mutation.

    graphql_post_object_mutation_set_edit_lock

    Sets the post lock

    graphql_post_object_insert_post_args

    Filter the $insert_post_args

    graphql_post_object_create_should_set_intended_post_status

    Determine whether the intended status should be set or not. By filtering to false, the $intended_post_status will not be set at the completion of the mutation.

    graphql_post_object_create_default_post_status

    Filter the default post status to use when the post is initially created. Pass through a filter to allow other plugins to override the default (for example, Edit Flow, which provides control over customizing statuses or various E-commerce plugins that make heavy use of custom statuses)

    graphql_map_input_fields_to_wp_query

    Filter the input fields. This allows plugins/themes to hook in and alter what $args should be allowed to be passed from a GraphQL Query to the WP_Query.

    graphql_post_object_connection_query_args

    Filter the $query args to allow folks to customize queries programmatically

    graphql_resolve_revision_meta_from_parent

    Filters whether to resolve revision metadata from the parent node by default.

    graphql_return_modeled_data

    Filter the array of fields for the Model before the object is hydrated with it

    graphql_return_field_from_model

    Filter the data returned by the default callback for the field

    graphql_pre_return_field_from_model

    Filter to short circuit the callback for any field on a type. Returning anything other than null will stop the callback for the field from executing, and will return your data or execute your callback instead.

    graphql_model_field_capability

    Capability to check required for the field

    graphql_allowed_fields_on_restricted_type

    Filter for the allowed restricted fields

    graphql_object_visibility

    Filter the visibility name to be returned

    graphql_data_is_private

    Filter to determine if the data should be considered private or not

    graphql_restricted_data_cap

    Filter for the capability to check against for restricted data

    graphql_resolve_menu_item

    Allow users to override how nav menu items are resolved. This is useful since we often add taxonomy terms to menus but would prefer to represent the menu item in other ways, e.g., a linked post object (or vice-versa).

    graphql_media_item_insert_post_args

    Filter the $insert_post_args

    graphql_field_resolver_auth_error_message

    Filter the auth error

    graphql_resolve_field

    Fire an action before the field resolves

    graphql_pre_resolve_field

    When this filter return anything other than the $nil it will be used as the resolved value and the execution of the actual resolved is skipped. This filter can be used to implement field level caches or for efficiently hiding data by returning null.

    graphql_field_definition

    Filter the field definition

    graphql_debug_log

    Return the filtered debug log

    graphql_debug_log_entry

    Filter the log entry for the debug log

    graphql_resolve_node_type

    Add a filter to allow externally registered node types to return the proper type based on the node_object that’s returned

    graphql_allowed_setting_groups

    Filter the $allowed_settings to allow some to be enabled or disabled from showing in the GraphQL Schema

    graphql_allowed_settings_by_group

    Filter the $allowed_settings_by_group to allow enabling or disabling groups in the GraphQL Schema

    graphql_users_orderby

    Filters the ORDER BY clause of the query

    graphql_users_where

    Filters the WHERE clause of the query.

    graphql_comment_insert_post_args

    Filter the $insert_post_args

    graphql_map_input_fields_to_wp_comment_query

    Filter the input fields. This allows plugins/themes to hook in and alter what $args should be allowed to be passed from a GraphQL Query to the get comments query.

    graphql_comment_connection_query_args

    Filter the query_args that should be applied to the query. This filter is applied AFTER the input args from the GraphQL Query have been applied and has the potential to override the GraphQL Query Input Args.

    graphql_app_context_config

    This filters the config for the AppContext. This can be used to store additional context config, which is available to resolvers throughout the resolution of a GraphQL request.

    graphql_data_loaders

    This filters the data loaders, allowing for additional loaders to be added to the AppContext or for existing loaders to be replaced if needed.

    graphql_enable_graphiql

    Filter to determine if GraphiQL should be enabled.

    graphql_dataloader_get_model

    Filter the model before returning.

    graphql_dataloader_pre_get_model

    This filter allows the model generated by the DataLoader to be filtered. Returning anything other than null here will bypass the default model generation for an object.

    graphql_connection

    Filter the connection. In some cases, connections will want to provide additional information other than edges, nodes, and pageInfo. This filter allows additional fields to be returned to the connection resolver

    graphql_connection_edges

    Filters the edges in the connection

    graphql_connection_nodes

    Set the items. These are the “nodes” that make up the connection. Filters the nodes in the connection.

    graphql_connection_ids

    Filter the connection IDs

    graphql_connection_query

    Set the query for the resolver, for use as reference in filters, etc

    graphql_connection_should_execute

    Check if the connection should execute. If conditions are met that should prevent the execution, we can bail from resolving early, before the query is executed.

    graphql_connection_page_info

    Filter the pageInfo that is returned to the connection.

    graphql_connection_edge

    Create the edge, pass it through a filter.

    graphql_connection_amount_requested

    This filter allows to modify the requested connection page size

    graphql_connection_max_query_amount

    Filter the maximum number of posts per page that should be queried. The default is 100 to prevent queries from being exceedingly resource intensive, however individual systems can override this for their specific needs. This filter is intentionally applied AFTER the query_args filter.

    graphql_connection_query_args

    Get the Query Args. This accepts the input args and maps it to how it should be used in the WP_Query.

    graphql_type_registry

    Generate & Filter the schema.

    graphql_debug_enabled

    Filter to determine if GraphQL Debug is enabled

    graphql_schema

    Filter the Schema

    graphql_term_entities_allowed_taxonomies

    Returns the array of $allowed_taxonomies

    graphql_post_entities_allowed_post_types

    Define the $allowed_post_types to be exposed by GraphQL Queries Pass through a filter to allow the post_types to be modified (for example if a certain post_type should not be exposed to the GraphQL API)

    graphql_show_admin

    This filter can be used to disable or enable the GraphQL Admin pages with code.