From 561ab942341c2883005c08d17f9e722b4d6b9ef2 Mon Sep 17 00:00:00 2001 From: David Levine Date: Thu, 12 Jan 2023 17:48:30 +0000 Subject: [PATCH] chore: update changelog --- CHANGELOG.md | 24 ++++++++++-------- README.md | 71 ++++++++++++++++++++++++++-------------------------- 2 files changed, 49 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a29ea4b..682694c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,23 +1,25 @@ # Changelog -## Unreleased -- chore: update Composer dependencies. -- chore: switch `poolshark/wp-graphql-stubs` for `axepress/wp-graphql-stubs` -- chore: stub `FWP()` and FacetWP class properties. -- chore: change stubfile extensions to `.php`. -- dev: add explicit support for PHP 8.1. -- dev: use `camelCase` for FacetQueryArgs field names by default. Fields using `snake_case` have been deprecated and will be removed in a future version. +## v0.4.1 +This _minor_ release introduces WPGraphQL-specific field properties to the Facet configuration array and adds the corresponding `get_graphql_allowed_facets()` access function. It also deprecates the usage `snake_case` autogenerated field names in the `FacetQueryArgs` input type in favor of `camelCase`, and adds explicit support for PHP 8.1. + +- feat: add `show_in_graphql` and `graphql_field_name` to the Facet configuration. +- feat: add explicit PHP 8.1 support. +- feat: deprecate usage of `snake_case` field names in `FacetQueryArgs` input type, in favor of `camelCase`. - dev: add `get_graphql_allowed_facets()` access function. -- dev: allow for (programmatically) overwriting GraphQL-specific field properties. - dev: refactor facet input types to use the `graphql_type` config property generated by `FacetRegistry::get_facet_input_type()`. - dev: add the following WordPress filters: `graphql_facetwp_facet_input_type`. -- tests: chang `FWPGraphQLTestCase.php::register_facet()` add facet instead of replace it. +- chore: update Composer dependencies. +- chore: replace `poolshark/wp-graphql-stubs` dev dependency with `axepress/wp-graphql-stubs` +- chore: stub `FWP()` function and `FacetWP` class properties. +- chore: change stubfile extensions to `.php`. +- tests: change `FWPGraphQLTestCase.php::register_facet()` to add a new facet instead of replace it. -## v.0.4.0 +## v0.4.0 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 version of WPGraphQL to `v1.6.1`. - feat!: Bump minimum PHP version to `v7.4`. - feat!: Bump minimum FacetWP version to `v4.0`. - fix: Implement `WPVIP` PHP coding standards. diff --git a/README.md b/README.md index 1eb54fe..7323246 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ This plugin has been tested and is functional with SearchWP. * WordPress 5.4.1+ * WPGraphQL 1.6.0+ (1.9.0+ recommended) * FacetWP 4.0 + ## Quick Install 1. Install & activate [WPGraphQL](https://www.wpgraphql.com/). @@ -90,9 +91,9 @@ query GetPostsByFacet( $query: FacetQueryArgs, $after: String, $search: String, } posts ( # The results of the facet query. Can be filtered by WPGraphQL connection where args first: 10, - after: $after, - where: { search: $search, orderby: $orderBy} - ) { + after: $after, + where: { search: $search, orderby: $orderBy} + ) { pageInfo { hasNextPage endCursor @@ -112,41 +113,41 @@ Support for WooCommerce Products can be added with following configuration: ```php add_action( 'graphql_register_types', function () { - register_graphql_facet_type( 'product' ); + register_graphql_facet_type( 'product' ); }); add_filter( 'facetwp_graphql_facet_connection_config', - function ( array $default_graphql_config, array $config ) { - $type = $config['type']; - $singular = $config['singular']; - $field = $config['field']; - $plural = $config['plural']; - - return [ - 'fromType' => $field, - 'toType' => $singular, - 'fromFieldName' => lcfirst( $plural ), - 'connectionArgs' => 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 ) { - $resolver = new PostObjectConnectionResolver( $source, $args, $context, $info, $type); - - if ( $type === 'product' ) { - $resolver = Products::set_ordering_query_args( $resolver, $args ); - } - - if( ! empty( $source['results'] ) ) { - $resolver->->set_query_arg( 'post__in', $source['results'] ); - } - - return $resolver ->get_connection(); - }, - ]; - }, - 100, - 2 + function ( array $default_graphql_config, array $config ) { + $type = $config['type']; + $singular = $config['singular']; + $field = $config['field']; + $plural = $config['plural']; + + return [ + 'fromType' => $field, + 'toType' => $singular, + 'fromFieldName' => lcfirst( $plural ), + 'connectionArgs' => 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 ) { + $resolver = new PostObjectConnectionResolver( $source, $args, $context, $info, $type); + + if ( $type === 'product' ) { + $resolver = Products::set_ordering_query_args( $resolver, $args ); + } + + if( ! empty( $source['results'] ) ) { + $resolver->->set_query_arg( 'post__in', $source['results'] ); + } + + return $resolver ->get_connection(); + }, + ]; + }, + 100, + 2 ); ```