Skip to content

Commit a7714d0

Browse files
kidunot89jasonbahl
andauthored
Updates to be compatible with WPGraphQL v1.6.1 (#537)
* fix: Huge refactor across schema and unit tests * - add shipping_method loader in class-core-schema-filters.php * - Update class-wc-db-loader.php to respect the new SHIPPING_METHOD loader with a `load_shipping_method_from_id()` function * - Convert Shipping_Method_Connection_Resolver to extend AbstractConnectionResolver * - Replace resolver for Shipping Methods connection. Remove use of `resolveNode` and replace the resolver with the new connection class `get_connection()` call * chore: Factory class refactored. * - update the function that registers Product Types to the Schema to use the value from the `get_enabled_product_types()` as the Type name and the key as the fieldName * chore: PaymentGatewayQueriesTest refactored. * chore: WPCS compliance met * chore: Syntax error fixed. Co-authored-by: Jason Bahl <[email protected]>
1 parent 4451c32 commit a7714d0

40 files changed

+1016
-1291
lines changed

bin/_env.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
set +u
24

35
if [[ -z "$DB_NAME" ]]; then

bin/_lib.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ install_wordpress() {
2121

2222
# Install Wordpress + integrated plugins for testing/development.
2323
composer install
24-
composer require --dev composer/installers \
24+
composer require --dev -W \
25+
composer/installers:~1.0 \
2526
johnpbloch/wordpress:~${WP_VERSION} \
2627
wp-graphql/wp-graphql-jwt-authentication \
2728
wpackagist-plugin/woocommerce \
2829
wpackagist-plugin/woocommerce-gateway-stripe \
2930
wpackagist-plugin/wp-graphql \
3031
wpackagist-theme/twentytwentyone \
31-
wp-cli/wp-cli-bundle
32+
wp-cli/wp-cli-bundle
3233
}
3334

3435
remove_wordpress() {

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/class-core-schema-filters.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,10 @@ public static function graphql_data_loaders( $loaders, $context ) {
254254
$loaders['downloadable_item'] = &$downloadable_item_loader;
255255
$tax_rate_loader = new WC_Db_Loader( $context, 'TAX_RATE' );
256256
$loaders['tax_rate'] = &$tax_rate_loader;
257-
257+
$order_item_loader = new WC_Db_Loader( $context, 'ORDER_ITEM' );
258+
$loaders['order_item'] = &$order_item_loader;
259+
$shipping_item_loader = new WC_Db_Loader( $context, 'SHIPPING_METHOD' );
260+
$loaders['shipping_method'] = &$shipping_item_loader;
258261
return $loaders;
259262
}
260263

includes/class-type-registry.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ public function init( \WPGraphQL\Registry\TypeRegistry $type_registry ) {
6565
\WPGraphQL\WooCommerce\Type\WPInterface\Cart_Error::register_interface( $type_registry );
6666

6767
// Objects.
68+
\WPGraphQL\WooCommerce\Type\WPObject\Meta_Data_Type::register();
69+
\WPGraphQL\WooCommerce\Type\WPObject\Downloadable_Item_Type::register();
6870
\WPGraphQL\WooCommerce\Type\WPObject\Coupon_Type::register();
6971
\WPGraphQL\WooCommerce\Type\WPObject\Product_Types::register();
7072
\WPGraphQL\WooCommerce\Type\WPObject\Product_Attribute_Types::register();
7173
\WPGraphQL\WooCommerce\Type\WPObject\Product_Variation_Type::register();
72-
\WPGraphQL\WooCommerce\Type\WPObject\Order_Type::register();
7374
\WPGraphQL\WooCommerce\Type\WPObject\Order_Item_Type::register();
74-
\WPGraphQL\WooCommerce\Type\WPObject\Downloadable_Item_Type::register();
75+
\WPGraphQL\WooCommerce\Type\WPObject\Order_Type::register();
7576
\WPGraphQL\WooCommerce\Type\WPObject\Refund_Type::register();
7677
\WPGraphQL\WooCommerce\Type\WPObject\Product_Download_Type::register();
7778
\WPGraphQL\WooCommerce\Type\WPObject\Customer_Type::register();
@@ -82,7 +83,6 @@ public function init( \WPGraphQL\Registry\TypeRegistry $type_registry ) {
8283
\WPGraphQL\WooCommerce\Type\WPObject\Simple_Attribute_Type::register();
8384
\WPGraphQL\WooCommerce\Type\WPObject\Variation_Attribute_Type::register();
8485
\WPGraphQL\WooCommerce\Type\WPObject\Payment_Gateway_Type::register();
85-
\WPGraphQL\WooCommerce\Type\WPObject\Meta_Data_Type::register();
8686
\WPGraphQL\WooCommerce\Type\WPObject\Shipping_Package_Type::register();
8787
\WPGraphQL\WooCommerce\Type\WPObject\Shipping_Rate_Type::register();
8888
\WPGraphQL\WooCommerce\Type\WPObject\Cart_Error_Types::register();
@@ -98,14 +98,11 @@ public function init( \WPGraphQL\Registry\TypeRegistry $type_registry ) {
9898
\WPGraphQL\WooCommerce\Connection\Coupons::register_connections();
9999
\WPGraphQL\WooCommerce\Connection\Products::register_connections();
100100
\WPGraphQL\WooCommerce\Connection\Orders::register_connections();
101-
\WPGraphQL\WooCommerce\Connection\Order_Items::register_connections();
102-
\WPGraphQL\WooCommerce\Connection\Downloadable_Items::register_connections();
103101
\WPGraphQL\WooCommerce\Connection\Product_Attributes::register_connections();
104102
\WPGraphQL\WooCommerce\Connection\Variation_Attributes::register_connections();
105103
\WPGraphQL\WooCommerce\Connection\Customers::register_connections();
106104
\WPGraphQL\WooCommerce\Connection\Tax_Rates::register_connections();
107105
\WPGraphQL\WooCommerce\Connection\Shipping_Methods::register_connections();
108-
\WPGraphQL\WooCommerce\Connection\Cart_Items::register_connections();
109106
\WPGraphQL\WooCommerce\Connection\Payment_Gateways::register_connections();
110107

111108
// Mutations.

includes/connection/class-cart-items.php

Lines changed: 0 additions & 97 deletions
This file was deleted.

includes/connection/class-coupons.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use GraphQL\Error\UserError;
1313
use GraphQL\Type\Definition\ResolveInfo;
1414
use WPGraphQL\AppContext;
15-
use WPGraphQL\WooCommerce\Data\Factory;
1615
use WPGraphQL\Data\Connection\PostObjectConnectionResolver;
1716

1817
/**

includes/connection/class-customers.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use GraphQL\Type\Definition\ResolveInfo;
1313
use WPGraphQL\AppContext;
1414
use WPGraphQL\Data\Connection\UserConnectionResolver;
15-
use WPGraphQL\WooCommerce\Data\Factory;
1615

1716
/**
1817
* Class - Customers

includes/connection/class-downloadable-items.php

Lines changed: 0 additions & 80 deletions
This file was deleted.

includes/connection/class-order-items.php

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)