WPGraphQL for FacetWP
This FREE plugin from @hsimah exposes filters on WPGraphQL queries to allow for faceted search with FacetWP
Community PluginView Plugin on Github
Download and install like any WordPress plugin.
- Requires WPGraphQL 0.8.1+
- Requires FacetWP 188.8.131.52+
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.
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:
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.
A simple query might look like this:
Currently the plugin only has been tested using Checkbox and Radio facet types. Support for additional types is in development.