Skip to content

Commit 7ad701e

Browse files
committed
Merge branch 'develop' of github.com:wp-graphql/wp-graphql-woocommerce into develop
2 parents dc91774 + f4571b6 commit 7ad701e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+642
-444
lines changed

.github/workflows/testing-integration.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Testing Integration
22

33
on:
4+
schedule:
5+
- cron: '* * */7 * *'
46
push:
57
branches:
68
- develop

README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Requires at least: 4.9
55
Tested up to: 5.2
66
Requires PHP: 7.0
77
Requires WooCommerce: 3.0.0
8-
Requires WPGraphQL: 0.6.0+
8+
Requires WPGraphQL: 0.8.0+
99
Works with WPGraphQL-JWT-Authentication: 0.4.0+
1010
Stable tag: 0.4.4
1111
License: GPL-3

bin/install-wp-tests.sh renamed to bin/install-test-env.sh

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -110,35 +110,6 @@ install_wp() {
110110
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
111111
}
112112

113-
install_test_suite() {
114-
# portable in-place argument for both GNU sed and Mac OSX sed
115-
if [[ $(uname -s) == 'Darwin' ]]; then
116-
local ioption='-i.bak'
117-
else
118-
local ioption='-i'
119-
fi
120-
121-
# set up testing suite if it doesn't yet exist
122-
if [ ! -d $WP_TESTS_DIR ]; then
123-
# set up testing suite
124-
mkdir -p $WP_TESTS_DIR
125-
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
126-
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
127-
fi
128-
129-
if [ ! -f wp-tests-config.php ]; then
130-
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
131-
# remove all forward slashes in the end
132-
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
133-
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
134-
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
135-
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
136-
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
137-
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
138-
fi
139-
140-
}
141-
142113
install_db() {
143114

144115
if [ ${SKIP_DB_CREATE} = "true" ]; then
@@ -215,7 +186,6 @@ setup_plugin() {
215186
}
216187

217188
install_wp
218-
install_test_suite
219189
install_db
220190
configure_wordpress
221191
setup_woocommerce

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
"autoload": {
3434
"files":[
35-
"includes/connection/common-post-type-args.php",
35+
"includes/connection/wc-cpt-connection-args.php",
3636
"includes/functions.php"
3737
],
3838
"psr-4": {
@@ -43,7 +43,7 @@
4343
]
4444
},
4545
"scripts": {
46-
"install-wp-tests": "bash bin/install-wp-tests.sh",
46+
"install-test-env": "bash bin/install-test-env.sh",
4747
"test": "vendor/bin/codecept run",
4848
"functional-test": "vendor/bin/codecept run functional",
4949
"acceptance-test": "vendor/bin/codecept run acceptance",

includes/class-core-schema-filters.php

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,14 @@
99
namespace WPGraphQL\WooCommerce;
1010

1111
use WPGraphQL\WooCommerce\Data\Loader\WC_Customer_Loader;
12-
use WPGraphQL\WooCommerce\Data\Loader\WC_Post_Crud_Loader;
12+
use WPGraphQL\WooCommerce\Data\Loader\WC_CPT_Loader;
13+
use WPGraphQL\WooCommerce\Data\Loader\WC_Db_Loader;
1314
use WPGraphQL\WooCommerce\Data\Factory;
1415

1516
/**
1617
* Class Core_Schema_Filters
1718
*/
1819
class Core_Schema_Filters {
19-
/**
20-
* Stores instance WC_Customer_Loader
21-
*
22-
* @var WC_Customer_Loader
23-
*/
24-
private static $customer_loader;
25-
26-
/**
27-
* Stores instance WC_Post_Crud_Loader
28-
*
29-
* @var WC_Post_Crud_Loader
30-
*/
31-
private static $post_crud_loader;
32-
3320
/**
3421
* Register filters
3522
*/
@@ -104,34 +91,6 @@ public static function add_filters() {
10491
);
10592
}
10693

107-
/**
108-
* Initializes WC_Loader instance
109-
*
110-
* @param AppContext $context - AppContext.
111-
*
112-
* @return WC_Post_Crud_Loader
113-
*/
114-
public static function post_crud_loader( $context ) {
115-
if ( is_null( self::$post_crud_loader ) ) {
116-
self::$post_crud_loader = new WC_Post_Crud_Loader( $context );
117-
}
118-
return self::$post_crud_loader;
119-
}
120-
121-
/**
122-
* Initializes Customer_Loader instance
123-
*
124-
* @param AppContext $context - AppContext.
125-
*
126-
* @return WC_Customer_Loader
127-
*/
128-
public static function customer_loader( $context ) {
129-
if ( is_null( self::$customer_loader ) ) {
130-
self::$customer_loader = new WC_Customer_Loader( $context );
131-
}
132-
return self::$customer_loader;
133-
}
134-
13594
/**
13695
* Registers WooCommerce post-types to be used in GraphQL schema
13796
*
@@ -255,12 +214,20 @@ public static function register_taxonomy_args( $args, $taxonomy ) {
255214
*/
256215
public static function graphql_data_loaders( $loaders, $context ) {
257216
// WooCommerce customer loader.
258-
$customer_loader = self::customer_loader( $context );
217+
$customer_loader = new WC_Customer_Loader( $context );
259218
$loaders['wc_customer'] = &$customer_loader;
260219

261-
// WooCommerce crud object loader.
262-
$post_crud_loader = self::post_crud_loader( $context );
263-
$loaders['wc_post_crud'] = &$post_crud_loader;
220+
// WooCommerce CPT loader.
221+
$cpt_loader = new WC_CPT_Loader( $context );
222+
$loaders['wc_cpt'] = &$cpt_loader;
223+
224+
// WooCommerce DB loaders.
225+
$cart_item_loader = new WC_Db_Loader( $context, 'CART_ITEM' );
226+
$loaders['cart_item'] = &$cart_item_loader;
227+
$downloadable_item_loader = new WC_Db_Loader( $context, 'DOWNLOADABLE_ITEM' );
228+
$loaders['downloadable_item'] = &$downloadable_item_loader;
229+
$tax_rate_loader = new WC_Db_Loader( $context, 'TAX_RATE' );
230+
$loaders['tax_rate'] = &$tax_rate_loader;
264231

265232
return $loaders;
266233
}

includes/connection/class-coupons.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ public static function get_connection_config( $args = array() ): array {
5050
'toType' => 'Coupon',
5151
'fromFieldName' => 'coupons',
5252
'connectionArgs' => self::get_connection_args(),
53-
'resolveNode' => function( $id, array $args, AppContext $context ) {
54-
return Factory::resolve_crud_object( $id, $context );
55-
},
56-
'resolve' => function ( $source, array $args, AppContext $context, ResolveInfo $info ) {
53+
'resolve' => function ( $source, $args, $context, $info ) {
5754
return Factory::resolve_coupon_connection( $source, $args, $context, $info );
5855
},
5956
),
@@ -68,7 +65,7 @@ public static function get_connection_config( $args = array() ): array {
6865
*/
6966
public static function get_connection_args(): array {
7067
return array_merge(
71-
get_common_post_type_args(),
68+
get_wc_cpt_connection_args(),
7269
array(
7370
'code' => array(
7471
'type' => 'String',

includes/connection/class-customers.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ public static function get_connection_config( $args ): array {
5454
return array_merge(
5555
array(
5656
'connectionArgs' => self::get_connection_args(),
57-
'resolveNode' => function( $id, array $args, AppContext $context ) {
58-
return Factory::resolve_customer( $id, $context );
59-
},
6057
'resolve' => function ( $source, array $args, AppContext $context, ResolveInfo $info ) {
6158
return Factory::resolve_customer_connection( $source, $args, $context, $info );
6259
},

includes/connection/class-orders.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ public static function get_connection_config( $args = array() ): array {
5454
'toType' => 'Order',
5555
'fromFieldName' => 'orders',
5656
'connectionArgs' => self::get_connection_args(),
57-
'resolveNode' => function( $id, $args, AppContext $context ) {
58-
return Factory::resolve_crud_object( $id, $context );
59-
},
6057
'resolve' => function ( $source, array $args, AppContext $context, ResolveInfo $info ) {
6158
return Factory::resolve_order_connection( $source, $args, $context, $info );
6259
},
@@ -75,7 +72,7 @@ public static function get_connection_args( $access = 'public' ): array {
7572
switch ( $access ) {
7673
case 'private':
7774
return array_merge(
78-
get_common_post_type_args(),
75+
get_wc_cpt_connection_args(),
7976
array(
8077
'statuses' => array(
8178
'type' => array( 'list_of' => 'OrderStatusEnum' ),

includes/connection/class-product-reviews.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public static function register_connections() {
4646
'type' => 'Float',
4747
'description' => __( 'Review rating', 'wp-graphql-woocommerce' ),
4848
'resolve' => function( $source ) {
49-
$rating = get_comment_meta( $source['node'], 'rating', true );
49+
$review = $source['node'];
50+
$rating = get_comment_meta( $review->commentId, 'rating', true );
5051
return $rating ? $rating : 0;
5152
},
5253
),

includes/connection/class-products.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ public static function get_connection_config( $args = array() ): array {
126126
'toType' => 'Product',
127127
'fromFieldName' => 'products',
128128
'connectionArgs' => self::get_connection_args(),
129-
'resolveNode' => function( $id, array $args, AppContext $context ) {
130-
return Factory::resolve_crud_object( $id, $context );
131-
},
132129
'resolve' => function( $source, array $args, AppContext $context, ResolveInfo $info ) {
133130
return Factory::resolve_product_connection( $source, $args, $context, $info );
134131
},
@@ -277,6 +274,6 @@ public static function get_connection_args(): array {
277274
);
278275
}
279276

280-
return array_merge( get_common_post_type_args(), $args );
277+
return array_merge( get_wc_cpt_connection_args(), $args );
281278
}
282279
}

0 commit comments

Comments
 (0)