Skip to content

Commit c7c48d7

Browse files
committed
stash progress
1 parent 8d248a7 commit c7c48d7

16 files changed

+20770
-50
lines changed

src/CoreSchemaFilters.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ public static function filter_connection_query_args( array $query_args, Abstract
5757
$payload = FWP()->api->process_request( $fwp_args );
5858

5959
return [
60-
'post__in' => ! empty( $payload['results'] ) ? $payload['results'] : [ 'no_results' ], // We use 'no_results' as a special value to indicate that the facet has no results.
61-
'fields' => 'ids',
60+
'post__in' => ! empty( $payload['results'] ) ? $payload['results'] : [ 'no_results' ], // We use 'no_results' as a special value to indicate that the facet has no results.
61+
'fields' => 'ids',
62+
'__fwp_payload' => $payload,
6263
];
6364
}
6465

@@ -77,6 +78,10 @@ public static function filter_connection_query( $query, AbstractConnectionResolv
7778

7879
$query_args = $resolver->get_query_args();
7980

81+
/**
82+
* Store the payload on the query object so that it can be accessed in the connection.
83+
*/
84+
8085
// If FWP finds no results, return null.
8186
if ( isset( $query_args['post__in'] ) && 'no_results' === $query_args['post__in'][0] ) {
8287
$resolver->set_query_arg( 'post__in', [] );

src/Type/Input/FacetsInput.php

+26
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
use GraphQL\Error\UserError;
1212
use WPGraphQL;
13+
use WPGraphQL\AppContext;
14+
use WPGraphQL\FacetWP\Type\WPInterface\FacetConfig;
1315
use WPGraphQL\FacetWP\Vendor\AxeWP\GraphQL\Abstracts\InputType;
1416

1517
/**
@@ -42,8 +44,32 @@ public static function register(): void {
4244
'description' => __( 'Filter by FacetWP facets.', 'wpgraphql-facetwp' ),
4345
],
4446
);
47+
48+
self::register_edge_field( $post_type_obj );
4549
}
4650
}
51+
52+
public static function register_edge_field( \WP_Post_Type $post_type_obj ) : void {
53+
register_graphql_edge_field(
54+
'RootQuery',
55+
$post_type_obj->graphql_single_name,
56+
'activeFacets',
57+
[
58+
'type' => [ 'list_of' => FacetConfig::get_type_name() ],
59+
'description' => __( 'The active facets on this connection', 'wpgraphql-facetwp' ),
60+
'resolve' => function( $source, array $args, AppContext $context ) {
61+
$keys = array_keys( (array) $source );
62+
foreach( $keys as $key ) {
63+
error_log( $key . ': ' . gettype( $source[$key] ) );
64+
}
65+
error_log($source['node']::class );
66+
error_log( $source['connection']::class );
67+
error_log( print_r($source['node'], true) );
68+
return [];
69+
},
70+
]
71+
);
72+
}
4773
/**
4874
* {@inheritDoc}
4975
*/

tests/_support/TestCase/FWPGraphQLTestCase.php

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class FWPGraphQLTestCase extends \Tests\WPGraphQL\TestCase\WPGraphQLTestCase {
2121
*/
2222
public function setUp() : void {
2323
parent::setUp();
24+
$this->clearFacets();
25+
$this->clearSchema();
26+
27+
unset( FWP()->helper->term_cache );
2428
}
2529

2630
/**

tests/wpunit/AccessFunctionsTest.php

-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ public function setUp(): void {
1818
$settings = get_option( 'graphql_general_settings' );
1919
$settings['public_introspection_enabled'] = 'on';
2020
update_option( 'graphql_general_settings', $settings );
21-
22-
$this->clearFacets();
2321
}
2422

2523
/**
@@ -28,8 +26,6 @@ public function setUp(): void {
2826
public function tearDown(): void {
2927
delete_option( 'graphql_general_settings' );
3028

31-
$this->clearFacets();
32-
3329
parent::tearDown();
3430
}
3531

tests/wpunit/CheckboxFacetTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ public function getQuery() : string {
140140
return '
141141
query GetPostsByFacet( $where: RootQueryToPostConnectionWhereArgs ) {
142142
posts( where: $where ) {
143+
edges {
144+
activeFacets{
145+
type
146+
name
147+
}
148+
}
143149
nodes {
144150
databaseId
145151
title

vendor/autoload.php

-18
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,6 @@
22

33
// autoload.php @generated by Composer
44

5-
if (PHP_VERSION_ID < 50600) {
6-
if (!headers_sent()) {
7-
header('HTTP/1.1 500 Internal Server Error');
8-
}
9-
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
10-
if (!ini_get('display_errors')) {
11-
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
12-
fwrite(STDERR, $err);
13-
} elseif (!headers_sent()) {
14-
echo $err;
15-
}
16-
}
17-
trigger_error(
18-
$err,
19-
E_USER_ERROR
20-
);
21-
}
22-
235
require_once __DIR__ . '/composer/autoload_real.php';
246

257
return ComposerAutoloaderInit67b8ec155949e29fef68cbc0ba7a77b0::getLoader();

vendor/composer/InstalledVersions.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
2222
*
2323
* To require its presence, you can require `composer-runtime-api ^2.0`
24-
*
25-
* @final
2624
*/
2725
class InstalledVersions
2826
{
2927
/**
3028
* @var mixed[]|null
31-
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
29+
* @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
3230
*/
3331
private static $installed;
3432

@@ -39,7 +37,7 @@ class InstalledVersions
3937

4038
/**
4139
* @var array[]
42-
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
40+
* @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
4341
*/
4442
private static $installedByVendor = array();
4543

@@ -243,7 +241,7 @@ public static function getInstallPath($packageName)
243241

244242
/**
245243
* @return array
246-
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
244+
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
247245
*/
248246
public static function getRootPackage()
249247
{
@@ -257,7 +255,7 @@ public static function getRootPackage()
257255
*
258256
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
259257
* @return array[]
260-
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
258+
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
261259
*/
262260
public static function getRawData()
263261
{
@@ -280,7 +278,7 @@ public static function getRawData()
280278
* Returns the raw data of all installed.php which are currently loaded for custom implementations
281279
*
282280
* @return array[]
283-
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
281+
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
284282
*/
285283
public static function getAllRawData()
286284
{
@@ -303,7 +301,7 @@ public static function getAllRawData()
303301
* @param array[] $data A vendor/composer/installed.php data set
304302
* @return void
305303
*
306-
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
304+
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
307305
*/
308306
public static function reload($data)
309307
{
@@ -313,7 +311,7 @@ public static function reload($data)
313311

314312
/**
315313
* @return array[]
316-
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
314+
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
317315
*/
318316
private static function getInstalled()
319317
{

vendor/composer/LICENSE

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Copyright (c) Nils Adermann, Jordi Boggiano
32

43
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -18,4 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1817
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1918
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2019
THE SOFTWARE.
21-

0 commit comments

Comments
 (0)