WPGraphQL FacetWP integration plguin

Overview

Logo

WPGraphQL-FacetWP: WPGraphQL provider for FacetWP

Quick Install

Download and install like any WordPress plugin.

Documentation

The WPGraphQL documentation can be found here. The FacetWP documentation can be found here.

  • Requires WPGraphQL 1.0.4+
  • Requires FacetWP 3.5.7+

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.

Usage:

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_register_types', 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.

A simple query might look like this:

query GetPosts($query: FacetQueryArgs, $after: String, $search: String, $orderBy: [PostObjectsConnectionOrderbyInput]) {
  postFacet(where: {status: PUBLISH, query: $query}) {
    facets {
      selected
      name
      label
      choices {
        value
        label
        count
      }
    }
    posts(first: 10, after: $after, where: {search: $search, orderby: $orderBy}) {
      pageInfo {
        hasNextPage
        endCursor
      }
      nodes {
        title
        excerpt
      }
    }
  }
}

Limitations

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

Comments
  • chore!: bump minimum PHP to v7.4

    chore!: bump minimum PHP to v7.4

    What

    Bumps the minimum required version to v7.4

    Why

    • The composer dependencies we'll need for WPUnit tests require v7.4, as do the latest versions of phpstan and phpstan-wordpress.
    • WPGraphQL itself requires a minimum v7.3, and is likely to bump to v7.4 in the next breaking release.
    • 7.3 reached its EOL a year ago.
    • Packagist stats show no usage below v7.4

    How

    Testing Instructions

    Additional Info

    Checklist:

    • [x] My code is tested to the best of my abilities.
    • [x] My code follows the WordPress Coding Standards.
    • [x] My code has proper inline documentation.
    safe to test βœ” 
    opened by justlevine 1
  • Fix!: Refactor plugin for WPGraphQL 1.6.0+ compatibility

    Fix!: Refactor plugin for WPGraphQL 1.6.0+ compatibility

    This PR is a complete refactor of the plugin to bring it up to date with the latest ecosystem patterns, make it more extensible for the future, and most importantly, make it compatible with the latest versions of WPGraphQL.

    Note: This PR contains breaking changes to the underlying PHP. The GraphQL schema and usage patterns remain the same.

    Highlights.

    • The entire plugin is now autoloaded with Composer.
    • Class WPGraphQL_FacetWP has been refactored to WPGraphQL\FacetWP\Main.
    • GraphQL types have been relocated to individual PHP classes in the WPGraphQL\FacetWP\Type namespace, and registered by WPGraphQL\FacetWP\Registry\TypeRegistry.
    • register_graphql_facet_type() has been relocated to access-functions.php and uses WPGraphQL\FacetWP\Registry\FacetRegistry to generate the necessary types.
    • All types are now registered on add_action( get_graphql_register_action(), ... ):. Note: As a result facet types are registered late (to be handled in a future PR).
    • The minimum WordPress version is now 5.0, and the minimum WPGraphQL version is now 1.6.0. Things should theoretically work in previous WPGraphQL versions.

    Screenshot

    image

    Additional Notes

    • Since WPGraphQL 1.6.0 implements lazy-loading types, the generic FacetWP types will only appear in the schema if register_graphql_facet_type() is called somewhere.
    • This PR includes (and depends on) the changes in #27 .
    • Ideally this should be merged after some basic WPUnit tests (I don't think I'm familiar enough yet with this plugin to implement them myself) and some GH Actions (e.g schema linting) are in place. This was a big PR and while most underlying cost is the same, just relocated, its better to be safe than sorry.
    • Currently the vendor autoloader is included in the repo, to ensure downloading the master branch continues to work. Once we start building releases with a CI, the vendor folder should be excluded from the repo.
    opened by justlevine 1
  • Chore: housekeeping

    Chore: housekeeping

    This PR:

    1. Updates the Plugin Headers with the latest version / requires info.
    2. Adds a readme.txt and a stub for CHANGELOG.md
    3. Updates composer.json to build deps at PHP v7.1, and adds PHPStan/PHPCS linting.
    4. Updates .gitignore and adds .distignore, .gitattributes, and .env.dist files
    5. PHPStan / Lint the existing plugin files.

    Notes:

    • No plugin functionality has been changed. This is strictly housekeeping.
    • The plugin version was changed to 0.3.0 - this seems to have been an oversight as the version tag exists.
    • The list of ignored files/directories in the various project files includes those that will be used by upcoming PRs (e.g. WPUnit Tests, CI, etc).
    opened by justlevine 1
  • Feature: Custom Facet Config

    Feature: Custom Facet Config

    Hi there, I added a custom filter that is called facetwp_graphql_facet_connection_config which allows developers to adjust the facet connection configuration. In my case I wanted to use the default woocommerce product graphql connection which is possible with the example in the docs.

    Looking forward to your feedback!

    opened by matteodem 1
  • release: 0.4.0

    release: 0.4.0

    What

    Version bump.

    Testing Instructions

    Additional Info

    Checklist:

    • [x] My code is tested to the best of my abilities.
    • [x] My code follows the WordPress Coding Standards.
    • [x] My code has proper inline documentation.
    safe to test βœ” 
    opened by justlevine 0
  • tests: add wpunit tests for `register_graphql_facet_type`

    tests: add wpunit tests for `register_graphql_facet_type`

    What

    Adds basic test for register_graphql_facet_type, fixing a few registration issues along the way.

    Why

    How

    Testing Instructions

    vendor/bin/codecept run wpunit

    Additional Info

    Checklist:

    • [x] My code is tested to the best of my abilities.
    • [x] My code follows the WordPress Coding Standards.
    • [x] My code has proper inline documentation.
    scope: tests πŸ§ͺ type: bug πŸ› safe to test βœ” 
    opened by justlevine 0
  • tests: configure codeception

    tests: configure codeception

    What

    Creates a basic codeception config, with an associated GH workflow.

    Why

    How

    Currently only plugin activation is tested.

    Testing Instructions

    1. Run composer install
    2. setup the test environment with composer install-test-env.
    3. Run vendor/bin/codecept run acceptance

    Additional Info

    Checklist:

    • [x] My code is tested to the best of my abilities.
    • [x] My code follows the WordPress Coding Standards.
    • [x] My code has proper inline documentation.
    type: chore 🧹 safe to test βœ” 
    opened by justlevine 0
  • chore: bump version to 0.3.0.1

    chore: bump version to 0.3.0.1

    What

    Bumps the pre-refactored plugin version to v0.3.0.1

    Why

    v0.3.0 was released without bumping the version number from 0.2.0. While normally this wouldn't be a big enough deal to backfill a release, because of the significant changes in #28 we want to make it clear what version users are actually using.

    Additional Info

    Checklist:

    • [x] My code is tested to the best of my abilities.
    • [x] My code follows the WordPress Coding Standards.
    • [x] My code has proper inline documentation.
    opened by justlevine 0
  • ci: use label to run pull_request_target

    ci: use label to run pull_request_target

    What

    Runs GH Actions on pull requests with the safe to test βœ” label.

    Why

    Since we need to use pull_request_target to test against FacetWP with a repo secret, we need a secure way to avoid pwn requests.

    How

    • ci: only run pull_request_target when the safe to test βœ” label is applied.
    • ci: use ramsey/composer-install@v2 to cache dependencies.

    Testing Instructions

    Additional Info

    Checklist:

    • [x] My code is tested to the best of my abilities.
    • [x] My code follows the WordPress Coding Standards.
    • [x] My code has proper inline documentation.
    opened by justlevine 0
  • Chore: add test environment and related workflows

    Chore: add test environment and related workflows

    This PR:

    • Add scripts to scaffold a test environment via composer or docker.
    • Adds GH workflows for PHPStan, GraphQL Schema Linting, and uploading artifacts to releases.

    Notes:

    • To build a test env, we need to be able to access a copy of facetwp. For local use, just edit .env to point to your gitified copy + PAT, but we need to add some secrets to the repo to get CI to work.
    • The workflows are written under the assumption that a main <- dev <- pr-branch merge flow will be adopted for the repo.
    • Schema linting and artifact uploading assumes the use of GitHub Releases for version bumps.
    • The CI for integration testing will be handled in a separate PR, since currently no tests have been written
    opened by justlevine 0
  • Chore: Add .github repo files

    Chore: Add .github repo files

    This PR adds templates for issues and pull requests, and a workflow for phpcs linting.

    Notes:

    • Other workflows are dependent on an actual WordPress install, which will require adding a GH secret to the repo to access a copy of facetwp for installation.
    • The templates are written under the assumption that GitHub discussions will be enabled for the repo.
    • The workflows are written under the assumption that a main <- dev <- pr-branch merge flow will be adopted for the repo.
    opened by justlevine 0
  • Autogenerate facets as connection where args

    Autogenerate facets as connection where args

    What problem does this address?

    Currently to use this plugin, you need to manually register_graphql_facet_type(), and then query the facet from RootQuery. That's a lot of manual work for the user, as well as more verbose queries.

    What is your proposed solution?

    We should be able to use the existing FacetWP data to autoregister facets to the schema out of the box, ideally as an input on the connections's {Type}ConnectionWhereArgs.

    Similarly, facet data can be added to the connection edge.

    E.g.

    query GetPosts($query: FacetQueryArgs, $after: String, $search: String, $orderBy: [PostObjectsConnectionOrderbyInput]) {
      posts(first: 10, after: $after, where: {status: PUBLISH, search: $search, orderby: $orderBy, facetQuery: $query }) {
        pageInfo {
          hasNextPage
          endCursor
        }
        selectedFacet {
          name
          label
          choices {
            value
            label
            count
          }
        }
        nodes {
          title
          excerpt
        }
      }
    }
    

    What alternatives have you considered?

    No response

    Additional Context

    This would be a non-breaking enhancement

    status: confirmed πŸ“ type: feature πŸ¦‹ 
    opened by justlevine 0
  • Add support for sort facet

    Add support for sort facet

    FacetWP has a sort facet that allows you to specify different ways to sort the returned data based on preset sort indexes. It would be great to have a sort GraphQL input type so that the data could be returned based on one of the preset sorts.

    status: confirmed πŸ“ type: enhancement ⚑ 
    opened by konstantinbrazhnik 3
  • Register a post type as a FacetWP queryable

    Register a post type as a FacetWP queryable

    I am trying to use your wp-graphql-facetwp plugin and register the "register_graphql_facet_type()". I followed the doc's but get Uncaught Error.

    WordPress v5.6 FacetWP v3.7 WPGraphQL v1.0.5

    I added the function call in the theme functions.php file. I also have a facet setup.

    // Register facet for Posts register_graphql_facet_type( 'post' );

    Uncaught Error: Call to undefined function register_graphql_facet_type() Stack trace: #0 wp-settings.php(525): include() #1 wp-config.php(99): require_once('/home/ionicexce...') #2 wp-load.php(37): require_once('/home/ionicexce...') #3 wp-admin/admin.php(34): require_once('/home/ionicexce...') #4 wp-admin/theme-editor.php(10): require_once('/home/ionicexce...') #5 {main}

    status: needs review 🧐 type: bug πŸ› 
    opened by excelify 1
  • Map string settings to appropriate types

    Map string settings to appropriate types

    FacetWP sends through 'yes' and 'no' for some settings. These really should be boolean values on the consumer end. Check other settings for similar issues.

    status: confirmed πŸ“ type: enhancement ⚑ 
    opened by hsimah 0
Releases(0.4.0)
  • 0.4.0(Sep 28, 2022)

    This major release refactors the underlying PHP codebase, bringing with it support for the latest versions of WPGraphQL and FacetWP. Care has been taken to ensure there are no breaking changes to the GraphQL schema.

    • feat!: Refactor plugin PHP classes and codebase structure to follow ecosystem patterns.
    • feat!: Bump minimum version of WPGraphQL to v1.6.0.
    • feat!: Bump minimum PHP version to v7.4.
    • feat!: Bump minimum FacetWP version to v4.0.
    • fix: Implement WPVIP PHP coding standards.
    • fix: Implement and meet PHPStan level 8 coding standards.
    • tests: Implement basic Codeception acceptance tests.
    • ci: Add Github workflows for PRs and releases.
    • chore: update Composer dependencies.
    • chore: switch commit flow to develop => main and set default branch to develop. The existing master branch will be removed on 1 October 2022.

    Full Changelog: https://github.com/hsimah-services/wp-graphql-facetwp/compare/0.3.0.1...0.4.0

    Source code(tar.gz)
    Source code(zip)
    schema.graphql(297.79 KB)
    wp-graphql-facetwp.zip(54.46 KB)
  • 0.3.0.1(Sep 28, 2022)

    Bumps the plugin version to v0.3.0.1 to address the missing version change in the previous release.

    Note: This is the last release on the master branch. Going forward, development will occur on the develop branch, with a snapshot of the latest release on main.

    The master branch will be removed from the repository on 1 October 2022.

    What's Changed

    • chore: bump version to 0.3.0.1 in https://github.com/hsimah-services/wp-graphql-facetwp/pull/36

    Full Changelog: https://github.com/hsimah-services/wp-graphql-facetwp/compare/0.3.0...0.3.0.1


    Rereleased on 28 Sep 2022 to generate release artifacts for GH Workflows.

    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Jun 19, 2022)

  • 0.2.0(Jan 4, 2021)

  • 0.1.1(May 26, 2020)

  • 0.1.0(Jul 3, 2019)

  • 0.0.1(Jun 14, 2019)

Owner
null
Enable query locking for WPGraphQL by implementing persisted GraphQL queries.

?? WP GraphQL Lock This plugin enables query locking for WPGraphQL by implementing persisted GraphQL queries. Persisted GraphQL queries allow a GraphQ

Valu Digital 21 Oct 9, 2022
WPGraphQL Extension: Adds "meta_query" support to postObject connection queries using WP_Query

WPGraphQL Meta Query This plugin adds Meta_Query support to the WP GraphQL Plugin for postObject query args. Why is this an extension and not part of

WPGraphQL 42 Nov 10, 2022
[ALPHA] Implementation of persisted queries for WPGraphQL

WPGraphQL Persisted Queries Persisted GraphQL queries allow a GraphQL client to optimistically send a hash of the query instead of the full query; if

Quartz 18 Jun 20, 2022
Send emails via mutation using WpGraphQl

WPGraphQL Send Email Plugin One of the simple things about a traditional WordPress sites is sending emails, this plugin makes it easy to do this via a

Ashley Hitchcock 18 Aug 21, 2022
An WPGraphQL extension that adds SearchWP's query functionality to the GraphQL server

QL Search What is QL Search? An extension that integrates SearchWP into WPGraphQL. Quick Install Install & activate SearchWP v3.1.9+ Install & activat

Funkhaus 11 May 5, 2022
Structured content blocks for WPGraphQL

WPGraphQL Content Blocks (Structured Content) This WPGraphQL plugin returns a WordPress post’s content as a shallow tree of blocks and allows for some

Quartz 72 Oct 3, 2022
WPGraphQL Polylang Extension for WordPress

WPGraphQL Polylang Extension Extend WPGraphQL schema with language data from the Polylang plugin. Features For posts and terms (custom ones too!) Adds

Valu Digital 102 Dec 29, 2022
a wordpress plugin that improves wpgraphql usage together with wpml

WPGraphQL WPML Extension Contributors: rburgst Stable tag: 1.0.6 Tested up to: 5.6.1 Requires at least: 4.9 Requires PHP: 7.0 Requires WPGraphQL: 0.8.

null 42 Dec 15, 2022
WPGraphQL for Advanced Custom Fields

WPGraphQL for Advanced Custom Fields WPGraphQL for Advanced Custom Fields automatically exposes your ACF fields to the WPGraphQL Schema. Install and A

WPGraphQL 558 Jan 8, 2023
Wordpress wrapper to expose Carbon Fields to WpGraphQL queries.

WpGraphQLCrb A Wordpress wrapper to expose Carbon Fields to WpGraphQL queries. Important This is just the first version. There is a lot of work to be

Matheus Paiva 16 Aug 19, 2022
Adds Settings to the Custom Post Type UI plugin to show Post Types in WPGraphQL

DEPRECATION NOTICE ?? Custom Post Type UI v1.9.0 introduced formal support for WPGraphQL!!! ?? With that, this plugin is being deprecated and will no

WPGraphQL 77 Aug 3, 2022
WPGraphQL for Meta Box

WPGraphQL-MetaBox: WPGraphQL provider for Meta Box Quick Install Download and install like any WordPress plugin. Documentation The WPGraphQL documenta

null 25 Aug 8, 2022
This is an extension to the WPGraphQL plugin for Yoast SEO

WPGraphQl Yoast SEO Plugin Please note version 14 of the Yoast Plugin is a major update. If you are stuck on version of Yoast before V14 then use v3 o

Ashley Hitchcock 197 Dec 26, 2022
Add WooCommerce support and functionality to your WPGraphQL server

WPGraphQL WooCommerce (WooGraphQL) Docs β€’ AxisTaylor β€’ Join Slack Quick Install Install & activate WooCommerce Install & activate WPGraphQL Download t

WPGraphQL 546 Jan 2, 2023
πŸš€WordPress Plugin Boilerplate using modern web techs like TypeScript, SASS, and so on... on top of a local development environment with Docker and predefined GitLab CI for continous integration and deployment!

WP React Starter: WordPress React Boilerplate DEPRECATED: WP React Starter was a "research project" of devowl.io for the development of our WordPress

devowl.io GmbH 344 Jan 1, 2023
Documents WordPress Classic Editor integration points and their Gutenberg equivalents

Gutenberg Migration Guide This repository documents WordPress Classic Editor customization points and their Gutenberg equivalents (if such exist). Its

Daniel Bachhuber 185 Nov 16, 2022
πŸš€ All-in-one enhancement plugin that improves WordPress & BuddyBoss integration.

=== Buddyboss Extended Add-on === Contributors: jcatama Donate link: https://www.paypal.me/jcatama Tags: buddyboss, buddypress, learndash, forums, gro

Albert Catama 1 Oct 12, 2022
A simple framework for running WordPress unit and integration tests.

Touchstone A modern wrapper around the official WordPress testsuite. It can be used to run both Unit and Integration tests. Installation Run the follo

Seb Kay 15 Jul 28, 2022
πŸš€ A distributed content delivery network (DCDN) integration plugin for wordpress

DCDN Engine - WordPress DCDN Plugin Simply integrate a Distributed Content Delivery Network (DCDN) into your WordPress site. Preview Plugin Installati

daqNext 6 Nov 30, 2022