PHPackages                             hsimah-services/wp-graphql-facetwp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. hsimah-services/wp-graphql-facetwp

ActiveWordpress-plugin[API Development](/categories/api)

hsimah-services/wp-graphql-facetwp
==================================

WPGraphQL integration for FacetWP

0.5.2(11mo ago)351002[4 issues](https://github.com/AxeWP/wp-graphql-facetwp/issues)[1 PRs](https://github.com/AxeWP/wp-graphql-facetwp/pulls)GPL-3.0-or-laterPHPPHP &gt;=7.4CI passing

Since Jan 4Pushed 11mo ago3 watchersCompare

[ Source](https://github.com/AxeWP/wp-graphql-facetwp)[ Packagist](https://packagist.org/packages/hsimah-services/wp-graphql-facetwp)[ GitHub Sponsors](https://github.com/sponsors/AxeWP)[ RSS](/packages/hsimah-services-wp-graphql-facetwp/feed)WikiDiscussions develop Synced yesterday

READMEChangelog (10)Dependencies (21)Versions (14)Used By (0)

[![Logo](./logo.png)](./logo.png)

WPGraphQL for FacetWP
=====================

[](#wpgraphql-for-facetwp)

Adds WPGraphQL support for [FacetWP](https://facetwp.com/).

- [Join the WPGraphQL community on Discord.](https://discord.gg/GyKncfmn7q)
- [Documentation](#usage)

---

[![Packagist License](https://camo.githubusercontent.com/3b4a768d0e6ec4a728f4d8e14be2987f9b8220ff205c85afcd35b538b24fe61d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6873696d61682d73657276696365732f77702d6772617068716c2d666163657477703f636f6c6f723d677265656e)](https://camo.githubusercontent.com/3b4a768d0e6ec4a728f4d8e14be2987f9b8220ff205c85afcd35b538b24fe61d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6873696d61682d73657276696365732f77702d6772617068716c2d666163657477703f636f6c6f723d677265656e) [![Packagist Version](https://camo.githubusercontent.com/ade23e3ff8ea378f58f809ad9a589cbd99c09b4d993e9e46df5c6d8f8ae6f46c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6873696d61682d73657276696365732f77702d6772617068716c2d666163657477703f6c6162656c3d737461626c65)](https://camo.githubusercontent.com/ade23e3ff8ea378f58f809ad9a589cbd99c09b4d993e9e46df5c6d8f8ae6f46c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6873696d61682d73657276696365732f77702d6772617068716c2d666163657477703f6c6162656c3d737461626c65) [![GitHub commits since latest release (by SemVer)](https://camo.githubusercontent.com/2bbc2c3b3d9531e463be9993d2e3468bafd2a5b6fdc05cf96fa23798e38e367f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6d6d6974732d73696e63652f41786557502f77702d6772617068716c2d666163657477702f302e352e32)](https://camo.githubusercontent.com/2bbc2c3b3d9531e463be9993d2e3468bafd2a5b6fdc05cf96fa23798e38e367f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6d6d6974732d73696e63652f41786557502f77702d6772617068716c2d666163657477702f302e352e32) [![GitHub forks](https://camo.githubusercontent.com/9d5ad12f88cd2f25fe044d5438a8274f20190d4cccb4e34898ad30fcfe072362/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f41786557502f77702d6772617068716c2d666163657477703f7374796c653d736f6369616c)](https://camo.githubusercontent.com/9d5ad12f88cd2f25fe044d5438a8274f20190d4cccb4e34898ad30fcfe072362/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f41786557502f77702d6772617068716c2d666163657477703f7374796c653d736f6369616c) [![GitHub Repo stars](https://camo.githubusercontent.com/879ac2b83d00b4f3fd1e9e7d0aeffc2bae2b1e73caca72f67d05873867afd51d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f41786557502f77702d6772617068716c2d666163657477703f7374796c653d736f6369616c)](https://camo.githubusercontent.com/879ac2b83d00b4f3fd1e9e7d0aeffc2bae2b1e73caca72f67d05873867afd51d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f41786557502f77702d6772617068716c2d666163657477703f7374796c653d736f6369616c)
[![CodeQuality](https://camo.githubusercontent.com/dfc47e244864833f5ab3200f5fd63bc5ecf288adec73ddbe5d8b0075aa335b1e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f41786557502f77702d6772617068716c2d666163657477702f636f64652d7175616c6974792e796d6c3f6272616e63683d646576656c6f70266c6162656c3d436f64652532305175616c697479)](https://camo.githubusercontent.com/dfc47e244864833f5ab3200f5fd63bc5ecf288adec73ddbe5d8b0075aa335b1e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f41786557502f77702d6772617068716c2d666163657477702f636f64652d7175616c6974792e796d6c3f6272616e63683d646576656c6f70266c6162656c3d436f64652532305175616c697479)[![GitHub Workflow Status](https://camo.githubusercontent.com/5f16abc353c8cdbcd505acc7caace534493d971a85411e81b7b525335b86b78c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f41786557502f77702d6772617068716c2d666163657477702f696e746567726174696f6e2d74657374696e672e796d6c3f6272616e63683d646576656c6f70266c6162656c3d496e746567726174696f6e25323054657374696e67)](https://camo.githubusercontent.com/5f16abc353c8cdbcd505acc7caace534493d971a85411e81b7b525335b86b78c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f41786557502f77702d6772617068716c2d666163657477702f696e746567726174696f6e2d74657374696e672e796d6c3f6272616e63683d646576656c6f70266c6162656c3d496e746567726174696f6e25323054657374696e67)[![Coding Standards](https://camo.githubusercontent.com/514620363a95657532abc186899e6c93f781652c4b2c2c13eb528c67d83984d0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f41786557502f77702d6772617068716c2d666163657477702f636f64652d7374616e646172642e796d6c3f6272616e63683d646576656c6f70266c6162656c3d576f72645072657373253230436f64696e672532305374616e6461726473)](https://camo.githubusercontent.com/514620363a95657532abc186899e6c93f781652c4b2c2c13eb528c67d83984d0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f41786557502f77702d6772617068716c2d666163657477702f636f64652d7374616e646172642e796d6c3f6272616e63683d646576656c6f70266c6162656c3d576f72645072657373253230436f64696e672532305374616e6461726473)

---

Overview
--------

[](#overview)

This plugin exposes configured facets through the graph schema. Once registered for a type, a query is available. The payload includes both facet choices and information and a connection to the post type data. This allows for standard GraphQL pagination of the returned data set.

This plugin has been tested and is functional with SearchWP.

System Requirements
-------------------

[](#system-requirements)

- PHP 7.4-8.1.x
- WordPress 5.4.1+
- WPGraphQL 1.6.0+ (1.9.0+ recommended)
- FacetWP 4.0+

Quick Install
-------------

[](#quick-install)

1. Install &amp; activate [WPGraphQL](https://www.wpgraphql.com/).
2. Install &amp; activate [FacetWP](https://facetwp.com/).
3. Download the `wp-graphql-facetwp.zip` file from the [latest release](https://github.com/AxeWP/wp-graphql-facetwp/releases/latest) upload it to your WordPress install, and activate the plugin.

Important

Make sure you are downloading the [`wp-graphql-facetwp.zip`](https://github.com/AxeWP/wp-graphql-facetwp/releases/latest/download/wp-graphql-facetwp.zip) file from the releases page, not the `Source code (zip)` file nor a clone of the repository.

If you wish to use the source code, you will need to run `composer install` inside the plugin folder to install the required dependencies.

### With Composer

[](#with-composer)

```
composer require hsimah-services/wp-graphql-facetwp
```

Updating and Versioning
-----------------------

[](#updating-and-versioning)

As we work towards a 1.0 Release, we will need to introduce **numerous** breaking changes. We will do our best to group multiple breaking changes together in a single release, to make it easier on developers to keep their projects up-to-date.

Until we hit v1.0, we're using a modified version of [SemVer](https://semver.org/), where:

- v0.**x**: "Major" releases. These releases introduce new features, and *may* contain breaking changes to either the PHP API or the GraphQL schema
- v0.x.**y**: "Minor" releases. These releases introduce new features and enhancements and address bugs. They *do not* contain breaking changes.
- v0.x.y.**z**: "Patch" releases. These releases are reserved for addressing issue with the previous release only.

Development and Support
-----------------------

[](#development-and-support)

WPGraphQL for FacetWP was initially created by [Hamish Blake](https://www.hsimah.com/). Maintenance and development are now provided by [AxePress Development](https://axepress.dev/). On 15 February 2025, the repository was transferred from  to .

Community contributions are *welcome* and **encouraged**.

Basic support is provided for free, both in [this repo](https://github.com/AxeWP/wp-graphql-facetwp/issues) and at the `#facetwp` channel in [WPGraphQL Discord](https://discord.gg/GyKncfmn7q).

Priority support and custom development is available to [AxePress Development sponsors](https://github.com/sponsors/AxeWP).

Usage:
------

[](#usage)

- *The WPGraphQL documentation can be found [here](https://docs.wpgraphql.com).*
- *The FacetWP documentation can be found [here](https://facetwp.com/documentation/).*

### Registering a facet to WPGraphQL

[](#registering-a-facet-to-wpgraphql)

**It is assumed that facets have been configured.**

To register a FacetWP query in the WPGraphQL schema for a WordPress post type (eg `post`) simply call the following function:

```
// Register facet for Posts
add_action( 'graphql_facetwp_init', function () {
  register_graphql_facet_type( 'post' );
} );
```

This will create a WPGraphQL `postFacet` field on the `RootQuery`. The payload includes a collection of queried `facets` and a `posts` connection. The connection is a standard WPGraphQL connection supporting pagination and server side ordering. The connection payload only includes filtered posts.

### Example query

[](#example-query)

**Note** This is not a complete list of GraphQL fields and types added to the schema. Please refer to the WPGraph**i**QL IDE for more queries and their documentation.

```
query GetPostsByFacet( $query: FacetQueryArgs, $after: String, $search: String, $orderBy: [PostObjectsConnectionOrderbyInput] ) {
  postFacet(
    where: {
      status: PUBLISH,
      query: $query # The query arguments are determined by the Facet type.
    }
  ) {
    facets { # The facet configuration
      selected
      name
      label
      choices {
        value
        label
        count
      }
    }
    posts ( # The results of the facet query. Can be filtered by WPGraphQL connection where args
      first: 10,
      after: $after,
      where: { search: $search, orderby: $orderBy} # The `orderby` arg is ignored if using the Sort facet.
    ) {
      pageInfo {
        hasNextPage
        endCursor
      }
      nodes {
        title
        excerpt
      }
    }
  }
}
```

### WooCommerce Support

[](#woocommerce-support)

Support for WooCommerce Products can be added with following configuration:

```
// This is the same as all CPTs.
add_action( 'graphql_facetwp_init', function () {
  register_graphql_facet_type( 'product' );
});

// This is required because WooGQL uses a custom connection resolver.
add_filter( 'facetwp_graphql_facet_connection_config',
  function ( array $default_graphql_config, array $facet_config ) {
    $type = $config['type'];

    $use_graphql_pagination = \WPGraphQL\FacetWP\Registry\FacetRegistry::use_graphql_pagination();

    return array_merge(
      $default_graphql_config,
      [
        'connectionArgs'    => \WPGraphQL\WooCommerce\Connection\Products::get_connection_args(),
        'resolveNode'       => function ( $node, $_args, $context ) use ( $type ) {
            return $context->get_loader( $type )->load_deferred( $node->ID );
        },
        'resolve'           => function ( $source, $args, $context, $info ) use ( $type, $use_graphql_pagination ) {
          // If we're using FWP's offset pagination, we need to override the connection args.
            if ( ! $use_graphql_pagination ) {
              $args['first'] = $source['pager']['per_page'];
            }

            $resolver = new \WPGraphQL\Data\Connection\PostObjectConnectionResolver( $source, $args, $context, $info, $type );

            // Override the connection results with the FWP results.
            if( ! empty( $source['results'] ) ) {
              $resolver->->set_query_arg( 'post__in', $source['results'] );
            }

            // Use post__in when delegating sorting to FWP.
            if ( ! empty( $source['is_sort'] ) ) {
              $resolver->set_query_arg( 'orderby', 'post__in' );
            } elseif( 'product' === $type ) {
              // If we're relying on WPGQL to sort, we need to to handle WooCommerce meta.
              $resolver = Products::set_ordering_query_args( $resolver, $args );
            }

            return $resolver ->get_connection();
        },
      ]
    );
  },
  100,
  2
);
```

### Limitations

[](#limitations)

Currently the plugin only has been tested using Checkbox, Radio, and Sort facet types. Support for additional types is in development.

Testing
-------

[](#testing)

1. Update your `.env` file to your testing environment specifications.
2. Run `composer install-test-env` to create the test environment.
3. Run your test suite with [Codeception](https://codeception.com/docs/02-GettingStarted#Running-Tests). E.g. `vendor/bin/codecept run wpunit` will run all WPUnit tests.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance50

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~161 days

Recently: every ~188 days

Total

11

Last Release

339d ago

PHP version history (4 changes)0.2.0PHP ^7.1||^8.0

0.4.0PHP ^7.4||^8.0

0.4.1PHP &gt;=7.4, &lt;=8.1

0.5.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/33212bff2915bd72792772a2d3203abe0402352b6be6ba65081036f10560c6e6?d=identicon)[justlevine](/maintainers/justlevine)

![](https://www.gravatar.com/avatar/895ef5d827a0d137430adeedb3c99a260d8e2c7ac5e193aaf0e114d46e7d09dd?d=identicon)[hsimah](/maintainers/hsimah)

---

Top Contributors

[![justlevine](https://avatars.githubusercontent.com/u/29322304?v=4)](https://github.com/justlevine "justlevine (81 commits)")[![hsimah](https://avatars.githubusercontent.com/u/10041901?v=4)](https://github.com/hsimah "hsimah (29 commits)")[![konstantinbrazhnik](https://avatars.githubusercontent.com/u/7378617?v=4)](https://github.com/konstantinbrazhnik "konstantinbrazhnik (1 commits)")[![matteodem](https://avatars.githubusercontent.com/u/1301147?v=4)](https://github.com/matteodem "matteodem (1 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/hsimah-services-wp-graphql-facetwp/health.svg)

```
[![Health](https://phpackages.com/badges/hsimah-services-wp-graphql-facetwp/health.svg)](https://phpackages.com/packages/hsimah-services-wp-graphql-facetwp)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
