Skip to content

Commit

Permalink
Merge pull request #45 from AxeWP/release/0.4.1
Browse files Browse the repository at this point in the history
release: v0.4.1
  • Loading branch information
justlevine authored Jan 12, 2023
2 parents 6aa07bd + 561ab94 commit 5d40b6d
Show file tree
Hide file tree
Showing 28 changed files with 82 additions and 80 deletions.
24 changes: 13 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
73 changes: 37 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Adds WPGraphQL support for [FacetWP](https://facetwp.com/).
* [Documentation](#usage)
-----

![Packagist License](https://img.shields.io/packagist/l/hsimah-services/wp-graphql-facetwp?color=green) ![Packagist Version](https://img.shields.io/packagist/v/hsimah-services/wp-graphql-facetwp?label=stable) ![GitHub commits since latest release (by SemVer)](https://img.shields.io/github/commits-since/hsimah-services/wp-graphql-facetwp/0.4.0) ![GitHub forks](https://img.shields.io/github/forks/hsimah-services/wp-graphql-facetwp?style=social) ![GitHub Repo stars](https://img.shields.io/github/stars/hsimah-services/wp-graphql-facetwp?style=social)<br />
![Packagist License](https://img.shields.io/packagist/l/hsimah-services/wp-graphql-facetwp?color=green) ![Packagist Version](https://img.shields.io/packagist/v/hsimah-services/wp-graphql-facetwp?label=stable) ![GitHub commits since latest release (by SemVer)](https://img.shields.io/github/commits-since/hsimah-services/wp-graphql-facetwp/0.4.1) ![GitHub forks](https://img.shields.io/github/forks/hsimah-services/wp-graphql-facetwp?style=social) ![GitHub Repo stars](https://img.shields.io/github/stars/hsimah-services/wp-graphql-facetwp?style=social)<br />
![CodeQuality](https://img.shields.io/github/workflow/status/hsimah-services/wp-graphql-facetwp/Code%20Quality?label=Code%20Quality)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/hsimah-services/wp-graphql-facetwp/Integration%20Testing?label=Integration%20Testing)
![Coding Standards](https://img.shields.io/github/workflow/status/hsimah-services/wp-graphql-facetwp/WordPress%20Coding%20Standards?label=WordPress%20Coding%20Standards)
Expand All @@ -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/).
Expand Down Expand Up @@ -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
Expand All @@ -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
);
```

Expand Down
4 changes: 2 additions & 2 deletions access-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This file contains access functions for various class methods.
*
* @package WPGraphQL/FacetWP
* @since @todo
* @since 0.4.0
*/

use WPGraphQL\FacetWP\Registry\FacetRegistry;
Expand Down Expand Up @@ -38,7 +38,7 @@ function() use ( $type_name ) {
/**
* Get the facets that are allowed to be queried via GraphQL.
*
* @since @todo
* @since 0.4.1
*/
function get_graphql_allowed_facets() : array {
return FacetRegistry::get_allowed_facets();
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Requires at least: 5.4.1
Requires PHP: 7.4
Requires FacetWP: 4.0
Requires WPGraphQL: 1.6.0
Tested up to: 6.0.2
Stable tag: 0.4.0
Tested up to: 6.1
Stable tag: 0.4.1
Maintained at: https://github.com/hsimah-services/wp-graphql-facetwp
License: GPL-3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/EnumType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Interface for a GraphQL EnumType.
*
* @package WPGraphQL\FacetWP\Interfaces
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Interfaces;
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/GraphQLType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Interface for classes that register a GraphQL type to the GraphQL schema.
*
* @package WPGraphQL\FacetWP\Interfaces
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Interfaces;
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/Initializable.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Interface for classes containing WordPress action/filter hooks.
*
* @package WPGraphQL\FacetWP\Interfaces;
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Interfaces;
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/TypeWithDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Interface for a GraphQL TypeWithDescription.
*
* @package WPGraphQL\FacetWP\Interfaces
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Interfaces;
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/TypeWithFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Interface for a GraphQL TypeWithFields.
*
* @package WPGraphQL\FacetWP\Interfaces
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Interfaces;
Expand Down
2 changes: 1 addition & 1 deletion src/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Initializes a singleton instance of the plugin.
*
* @package WPGraphQL\FacetWP
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP;
Expand Down
7 changes: 3 additions & 4 deletions src/Registry/FacetRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
* Registers individual facetsto the GraphQL schema.
*
* @package WPGraphQL\FacetWP\Registry
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Registry;

use WPGraphQL;
use WPGraphQL\Connection\PostObjects;
use WPGraphQL\Data\Connection\PostObjectConnectionResolver;
use WPGraphQL\FacetWP\Type\Input;
Expand Down Expand Up @@ -60,7 +59,7 @@ function( $config ) {
*
* @return string|array
*
* @since @todo
* @since 0.4.1
*/
public static function get_facet_input_type( array $config ) {
// The default facet type is a list of strings.
Expand Down Expand Up @@ -304,7 +303,7 @@ function ( $prev, $cur ) {
'type' => $cur['graphql_type'],
'description' => sprintf(
// translators: The current Facet label.
__( 'DEPRECATED since @todo', 'wpgraphql-facetwp' ),
__( 'DEPRECATED since 0.4.1', 'wpgraphql-facetwp' ),
$cur['label']
),
'deprecationReason' => sprintf(
Expand Down
2 changes: 1 addition & 1 deletion src/Registry/TypeRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Registers Plugin types to the GraphQL schema.
*
* @package WPGraphQL\FacetWP\Registry
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Registry;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Abstract GraphQL Type.
*
* @package WPGraphQL\FacetWP\Type
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Enum/AbstractEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Abstract GraphQL Enum Type.
*
* @package WPGraphQL\FacetWP\Type\Enum
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\Enum;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Enum/ProximityRadiusOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* GraphQL Enum Type - ProximityRadiusOptions.
*
* @package WPGraphQL\FacetWP\Type\Enum
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\Enum;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Input/AbstractInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Abstract GraphQL Input Type.
*
* @package WPGraphQL\FacetWP\Type\Input
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\Input;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Input/DateRangeArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* GraphQL Input Type - DateRangeArgs.
*
* @package WPGraphQL\FacetWP\Type\Input
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\Input;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Input/NumberRangeArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* GraphQL Input Type - NumberRangeArgs.
*
* @package WPGraphQL\FacetWP\Type\Input
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\Input;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Input/ProximityArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* GraphQL Input Type - ProximityArgs.
*
* @package WPGraphQL\FacetWP\Type\Input
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\Input;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Input/QueryArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* GraphQL Input Type - QueryArgs.
*
* @package WPGraphQL\FacetWP\Type\Input
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\Input;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Input/SliderArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* GraphQL Input Type - SliderArgs.
*
* @package WPGraphQL\FacetWP\Type\Input
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\Input;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/WPObject/AbstractObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Abstract GraphQL Object Type.
*
* @package WPGraphQL\FacetWP\Type\WPObject
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\WPObject;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/WPObject/Facet.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* GraphQL Object Type - Facet.
*
* @package WPGraphQL\FacetWP\Type\WPObject
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\WPObject;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/WPObject/FacetChoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* GraphQL Object Type - FacetChoice.
*
* @package WPGraphQL\FacetWP\Type\WPObject
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\WPObject;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/WPObject/FacetPager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* GraphQL Object Type - FacetPager.
*
* @package WPGraphQL\FacetWP\Type\WPObject
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\WPObject;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/WPObject/FacetRangeSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* GraphQL Object Type - FacetRangeSettings.
*
* @package WPGraphQL\FacetWP\Type\WPObject
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\WPObject;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/WPObject/FacetSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* GraphQL Object Type - FacetSettings.
*
* @package WPGraphQL\FacetWP\Type\WPObject
* @since @todo
* @since 0.4.0
*/

namespace WPGraphQL\FacetWP\Type\WPObject;
Expand Down
Loading

0 comments on commit 5d40b6d

Please sign in to comment.