Archives: Filters

  • graphql_post_object_mutation_set_edit_lock

    Sets the post lock

    apply_filters( 'graphql_post_object_mutation_set_edit_lock', bool $lock, int $post_id, array $input, WP_Post_Type $post_type_object, string $mutation_name, AppContext $context, ResolveInfo $info, string $default_post_status, string $intended_post_status );

    Params

    • $lock (bool): The post lock boolean
    • $input (array): The input for the mutation
    • $post_type_object (WP_Post_Type): The Post Type Object for the type of post being mutated
    • $mutation_name (string): The name of the mutation (ex: create, update, delete
    • $context (AppContext): The AppContext passed down to all resolvers
    • $info (ResolveInfo): The ResolveInfo passed down to all resolvers
    • $intended_post_status (string): The intended post_status the post should have according to the mutation input
    • $default_post_status (string): The default status posts should use if an intended status wasn’t set

  • graphql_post_object_insert_post_args

    Filter the $insert_post_args

    apply_filters( 'graphql_post_object_insert_post_args', array $insert_post_args, array $input, WP_Post_Type $post_type_object, string $mutation );
    

    Params

    • $insert_post_args (array): The array of $input_post_args that will be passed to wp_insert_post
    • $input (array): The data that was entered as input for the mutation
    • $post_type_object (WP_Post_Type): The post_type_object that the mutation is affecting
    • $mutation (string): The type of mutation being performed (create, edit, etc)

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

    This allows for side-effect actions to set the status later. For example, if a post was being created via a GraphQL Mutation, the post had additional required assets, such as images that needed to be sideloaded or some other semi-time-consuming side effect, those actions could be deferred (cron or whatever), and when those actions complete they could come back and set the $intended_status.

    apply_filters( 'graphql_post_object_create_should_set_intended_post_status', bool $should_set_inteneded_status, WP_Post_Type $post_type_object, string $mutation_name, AppContext $context, ResolveInfo $info, string $intended_post_status, string $default_post_status );

    Params

    • $should_set_intended_status (bool): Whether to set the intended post_status or not. Default true
    • $post_type_object (WP_Post_Type): The Post Type Object for the post being mutated
    • $mutation_name (string): The name of the mutation currently in progress
    • $context (AppContext): The AppContext passed down to all resolvers
    • $info (ResolveInfo): The ResolveInfo passed down to all resolvers
    • $intended_post_status (string): The intended post_status the post should have according to the mutation input
    • $default_post_status (string): The default status posts should use if an intended status wasn’t set
  • 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)

    apply_filters( 'graphql_post_object_create_default_post_status', string $default_status, WP_Post_Type $post_type_object, string $mutation_name );

    Params

    • $default_status (string): The default status to be used when the post is initially inserted
    • $post_type_object (WP_Post_Type): The Post Type that is being inserted
    • $mutation_name (string): The name of the mutation currently in progress
  • 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.

    apply_filters( 'graphql_map_input_fields_to_wp_query', array $query_args, array $where_args, mixed $source, array $all_args, AppContext $context, ResolveInfo $info, mixed|string|array $post_type );

    Params

    • $query_args (array): Array of mapped query args
    • $where_args (array): Array of query “where” args
    • $source (mixed): The query results
    • $all_args (array): All of the query arguments (not just the “where” args)
    • $context (AppContext): The AppContext object
    • $info (ResolveInfo): The ResolveInfo object
    • $post_type (mixed|string|array): The post type for the query
  • graphql_post_object_connection_query_args

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

    apply_filters( 'graphql_post_object_connection_query_args', array $query_args, mixed $source, array $args, AppContext $context, ResolveInfo $info );

    Params

    • $query_args (array): The args that will be passed to the WP_Query
    • $source (mixed): The source that’s passed down the GraphQL queries
    • $args (array): The inputArgs on the field
    • $context (AppContext): The AppContext passed down the GraphQL tree
    • $info (ResolveInfo): The ResolveInfo passed down the GraphQL tree
  • graphql_resolve_revision_meta_from_parent

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

    apply_filters( 'graphql_resolve_revision_meta_from_parent', bool $should, int $object_id, string $meta_key, bool $single );

    Params

    • $should (bool): Whether to resolve using the parent object. Default true.
    • $object_id (int): The ID of the object to resolve meta for
    • $meta_key (string): The key for the meta to resolve
    • $single (bool): Whether a single value should be returned
  • graphql_return_modeled_data

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

    apply_filters( 'graphql_return_modeled_data', array $fields, string $model_name, string $visibility, int $owner, WP_User $current_user );

    Params

    • $fields (array): The array of fields for the model
    • $model_name (array): Name of the model the filter is currently being executed in
    • $visibility (string): The visibility setting for this piece of data
    • $owner (null|int): The user ID for the owner of this piece of data
    • $current_user (WP_User): The current user for the session
  • graphql_return_field_from_model

    Filter the data returned by the default callback for the field

    apply_filters( 'graphql_return_field_from_model', string $field, string $key, string $model_name, mixed $data, string $visibility, int $owner, WP_User $current_user );

    Params

    • $field (string): The data returned from the callback
    • $key (string): The name of the field on the type
    • $model_name (string): Name of the model the filter is currently being executed in
    • $data (mixed): The un-modeled incoming data
    • $visibility (string): The visibility setting for this piece of data
    • $owner (null|int): The user ID for the owner of this piece of data
    • $current_user (WP_User): The current user for the session
  • 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.

    apply_filters( 'graphql_pre_return_field_from_model', null $return_field, string $key, string $model_name, mixed $data, string $visibility, int $owner, WP_User $current_user );

    Params

    • $return_field (null): The return field value, defaults to null
    • $model_name (string): Name of the model the filter is currently being executed in
    • $data (mixed): Name of the model the filter is currently being executed in
    • $visibility (string): The visibility setting for this piece of data
    • $owner (null|int): The user ID for the owner of this piece of data
    • $current_user (WP_User): The current user for the session