Archives: Filters

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

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

    Params

    • $query_args (array): Array of query_args
    • $source (mixed): Source passed down from the resolve tree
    • $args (array): Array of arguments input in the field as part of the GraphQL query
    • $context (AppContext): Object passed down the resolve tree
    • $info (ResolveInfo): Info about fields passed down the resolve tree
  • 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.

    apply_filters( 'graphql_app_context_config', $config );

    Params

    • $config (array): The config array of the AppContext object
  • 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.

    apply_filters( 'graphql_data_loaders', array $loaders, AppContext $context);

    Params

    • $loaders (array): The loaders accessible in the AppContext
    • $context (AppContext): The AppContext
  • graphql_enable_graphiql

    Filter to determine if GraphiQL should be enabled.

    apply_filters( 'graphql_enable_graphiql', bool $enabled );

    Params

    • $enabled (bool): Whether GraphiQL should be enabled

  • graphql_dataloader_get_model

    Filter the model before returning.

    apply_filters( 'graphql_dataloader_get_model', mixed $model, mixed $entry, mixed $key, AbstractDataLoader $loader );

    Params

    • $model (mixed): The Model to be returned by the loader
    • $entry (mixed): The entry loaded by dataloader that was used to create the Model
    • $key (mixed): The Key that was used to load the entry
    • $loader (AbstractDataLoader): The AbstractDataLoader Instance
  • 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.

    One example would be WooCommerce Products returning a custom Model for posts of post_type “product”.

    apply_filters( 'graphql_dataloader_pre_get_model', null $model, mixed $entry, mixed $key, AbstractDataLoader $loader );

    Params

    • $model (null|Model): The filtered model to return. Default null
    • $entry (mixed): The entry loaded from the dataloader to be used to generate a Model
    • $key (mixed): The Key used to identify the loaded entry
    • $loader (AbstractDataLoader): The AbstractDataLoader instance
  • 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

    apply_filters( 'graphql_connection', array $connection, AbstractConnectionResolver $resolver );

    Params

    • $connection (array): The connection data being returned
    • $resolver (AbstractConnectionResolver): The instance of the connection resolver
  • graphql_connection_edges

    Filters the edges in the connection

    apply_filters( 'graphql_connection_edges', array $nodes, AbstractConnectionResolver $resolver );

    Params

    • $nodes (array): The nodes in the connection
    • $resolver (AbstractConnectionResolver): Instance of the Connection Resolver
  • graphql_connection_nodes

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

    apply_filters( 'graphql_connection_nodes', array $nodes, AbstractConnectionResolver $resolver );

    Params

    • $nodes (array): The nodes in the connection
    • $resolver (AbstractConnectionResolver): Instance of the Connection Resolver
  • graphql_connection_ids

    Filter the connection IDs

    apply_filters( 'graphql_connection_ids', array $ids, AbstractConnectionResolver $resolver );

    Params

    • $ids (array): Array of IDs this connection will be resolving
    • $resolver (AbstractConnectionResolver): Instance of the Connection Resolver