Skip to content

Commit

Permalink
Origin/feature/update dependencies (#21)
Browse files Browse the repository at this point in the history
* update deprecated function calls

* update version
  • Loading branch information
hsimah authored Jan 4, 2021
1 parent c4a2a74 commit 25c98ec
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Download and install like any WordPress plugin.
The WPGraphQL documentation can be found [here](https://docs.wpgraphql.com).
The FacetWP documentation can be found [here](https://facetwp.com/documentation/).

- Requires WPGraphQL 0.8.1+
- Requires FacetWP 3.5.2.1+
- 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.
Expand All @@ -22,7 +22,9 @@ This plugin has been tested and is functional with SearchWP.
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
register_graphql_facet_type( 'post' );
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.
Expand Down
10 changes: 5 additions & 5 deletions class-facetwp.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ private function register_facet_connection($config)
'toType' => $singular,
'fromFieldName' => lcfirst($plural),
'connectionArgs' => PostObjects::get_connection_args(),
'resolveNode' => function ($node, $_args, $context, $_info) {
return !empty($node) ? DataSource::resolve_post_object($node->ID, $context) : null;
'resolveNode' => function ($node, $_args, $context) {
return $context->get_loader('post')->load_deferred($node->ID);
},
'resolve' => function ($source, $args, $context, $info) use ($type) {
$resolver = new PostObjectConnectionResolver($source, $args, $context, $info, $type);
$resolver->setQueryArg('post__in', $source['results']);

return $resolver->get_connection();
return $resolver
->set_query_arg('post__in', $source['results'])
->get_connection();
},
]);
}
Expand Down
10 changes: 5 additions & 5 deletions wp-graphql-facetwp.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

/**
* Plugin Name: WP GraphQL FacetWP
* Plugin URI: https://github.com/hsimah/wp-graphql-facetwp
* Plugin URI: https://github.com/hsimah-services/wp-graphql-facetwp
* Description: WP GraphQL provider for FacetWP
* Author: hsimah
* Author URI: http://www.hsimah.com
* Version: 0.1.1
* Version: 0.2.0
* Text Domain: wpgraphql-facetwp
* License: GPL-3
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
*
* @package WPGraphQL_FacetWP
* @author hsimah
* @version 0.1.1
* @version 0.2.0
*/

// Exit if accessed directly.
Expand All @@ -29,8 +29,8 @@

add_action('admin_init', function () {
$versions = [
'wp-graphql' => '0.8.1',
'facetwp' => '3.5.2.1',
'wp-graphql' => '1.0.4',
'facetwp' => '3.5.7',
];

if (
Expand Down

0 comments on commit 25c98ec

Please sign in to comment.