Skip to content

Commit

Permalink
Merge pull request wp-graphql#42 from kidunot89/release-v0.0.3-beta
Browse files Browse the repository at this point in the history
Release v0.0.3 beta
  • Loading branch information
kidunot89 committed Apr 25, 2019
2 parents 31d3b98 + 1c16fc3 commit 4781248
Show file tree
Hide file tree
Showing 51 changed files with 2,604 additions and 4,179 deletions.
32 changes: 10 additions & 22 deletions CHANGELOG.md
@@ -1,39 +1,27 @@
# Change Log

## [0.0.2](https://github.com/kidunot89/wp-graphql-woocommerce/tree/0.0.2) (2019-04-22)
[Full Changelog](https://github.com/kidunot89/wp-graphql-woocommerce/compare/0.0.1...0.0.2)
## [v0.0.3-beta](https://github.com/kidunot89/wp-graphql-woocommerce/tree/v0.0.3-beta) (2019-04-25)
[Full Changelog](https://github.com/kidunot89/wp-graphql-woocommerce/compare/v0.0.2-beta...v0.0.3-beta)

**Implemented enhancements:**

- TaxClass type [\#27](https://github.com/kidunot89/wp-graphql-woocommerce/issues/27)
- Order-Item type queries [\#13](https://github.com/kidunot89/wp-graphql-woocommerce/issues/13)
- Order items, TaxRate, and ShippingMethod [\#28](https://github.com/kidunot89/wp-graphql-woocommerce/pull/28) ([kidunot89](https://github.com/kidunot89))
- Where args for Coupon, Order, and Refund connections [\#24](https://github.com/kidunot89/wp-graphql-woocommerce/pull/24) ([kidunot89](https://github.com/kidunot89))
- Polishing Product types and connections [\#22](https://github.com/kidunot89/wp-graphql-woocommerce/pull/22) ([kidunot89](https://github.com/kidunot89))
- Testing and CI renovation [\#21](https://github.com/kidunot89/wp-graphql-woocommerce/pull/21) ([kidunot89](https://github.com/kidunot89))
- WC Post-type re-expansion [\#11](https://github.com/kidunot89/wp-graphql-woocommerce/pull/11) ([kidunot89](https://github.com/kidunot89))
- Customer/Order/Refund models, data-loaders, connections, types, and queries [\#10](https://github.com/kidunot89/wp-graphql-woocommerce/pull/10) ([kidunot89](https://github.com/kidunot89))
- WPGraphQL v0.3.0 migration [\#9](https://github.com/kidunot89/wp-graphql-woocommerce/pull/9) ([kidunot89](https://github.com/kidunot89))
- Replaces WP\_Query to WC\_Order\_Query in Order connections [\#38](https://github.com/kidunot89/wp-graphql-woocommerce/pull/38) ([kidunot89](https://github.com/kidunot89))
- Replaces WP\_Query to WC\_Product\_Query in Product connections [\#37](https://github.com/kidunot89/wp-graphql-woocommerce/pull/37) ([kidunot89](https://github.com/kidunot89))
- Pagination fix for CPT-backed CRUD objects connections [\#36](https://github.com/kidunot89/wp-graphql-woocommerce/pull/36) ([kidunot89](https://github.com/kidunot89))
- Cart-type and queries and customer query [\#30](https://github.com/kidunot89/wp-graphql-woocommerce/pull/30) ([kidunot89](https://github.com/kidunot89))

**Fixed bugs:**

- no queries work [\#31](https://github.com/kidunot89/wp-graphql-woocommerce/issues/31)
- after\_success script added [\#32](https://github.com/kidunot89/wp-graphql-woocommerce/pull/32) ([kidunot89](https://github.com/kidunot89))
- Polishing Product types and connections [\#22](https://github.com/kidunot89/wp-graphql-woocommerce/pull/22) ([kidunot89](https://github.com/kidunot89))
- Pagination broken [\#29](https://github.com/kidunot89/wp-graphql-woocommerce/issues/29)

**Closed issues:**

- v0.0.2-beta [\#33](https://github.com/kidunot89/wp-graphql-woocommerce/issues/33)
- Unsetting "object\_ids" on all connections [\#39](https://github.com/kidunot89/wp-graphql-woocommerce/issues/39)

**Merged pull requests:**

- Formatting code to WordPress Coding Standards [\#8](https://github.com/kidunot89/wp-graphql-woocommerce/pull/8) ([kidunot89](https://github.com/kidunot89))
- Feature/Product type [\#7](https://github.com/kidunot89/wp-graphql-woocommerce/pull/7) ([kidunot89](https://github.com/kidunot89))
- Feature/coupon type [\#6](https://github.com/kidunot89/wp-graphql-woocommerce/pull/6) ([kidunot89](https://github.com/kidunot89))
- Update issue templates [\#5](https://github.com/kidunot89/wp-graphql-woocommerce/pull/5) ([kidunot89](https://github.com/kidunot89))
- Create LICENSE [\#3](https://github.com/kidunot89/wp-graphql-woocommerce/pull/3) ([kidunot89](https://github.com/kidunot89))
- Create CODE\_OF\_CONDUCT.md [\#2](https://github.com/kidunot89/wp-graphql-woocommerce/pull/2) ([kidunot89](https://github.com/kidunot89))
- travis.yml updated [\#1](https://github.com/kidunot89/wp-graphql-woocommerce/pull/1) ([kidunot89](https://github.com/kidunot89))
- Master [\#35](https://github.com/kidunot89/wp-graphql-woocommerce/pull/35) ([kidunot89](https://github.com/kidunot89))
- Release v0.0.2 beta [\#34](https://github.com/kidunot89/wp-graphql-woocommerce/pull/34) ([kidunot89](https://github.com/kidunot89))



Expand Down
9 changes: 9 additions & 0 deletions src/class-actions.php
Expand Up @@ -12,14 +12,17 @@

use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Backorders;
use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Catalog_Visibility;
use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Customer_Connection_Orderby_Enum;
use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Discount_Type;
use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Manage_Stock;
use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Order_Status;
use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Product_Types;
use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Stock_Status;
use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Tax_Class;
use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Tax_Status;
use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\WC_Connection_Orderby_Enum;
use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Tax_Rate_Connection_Orderby_Enum;
use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Customer_Connection_Orderby_Input;
use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\WC_Connection_Orderby_Input;
use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Tax_Rate_Connection_Orderby_Input;
use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Coupon_Type;
Expand All @@ -35,6 +38,7 @@
use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Customer_Address_Type;
use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Tax_Rate_Type;
use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Shipping_Method_Type;
use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Cart_Type;
use WPGraphQL\Extensions\WooCommerce\Connection\Posts;
use WPGraphQL\Extensions\WooCommerce\Connection\WC_Terms;
use WPGraphQL\Extensions\WooCommerce\Connection\Coupons;
Expand All @@ -47,6 +51,7 @@
use WPGraphQL\Extensions\WooCommerce\Connection\Customers;
use WPGraphQL\Extensions\WooCommerce\Connection\Tax_Rates;
use WPGraphQL\Extensions\WooCommerce\Connection\Shipping_Methods;
use WPGraphQL\Extensions\WooCommerce\Connection\Cart_Items;

/**
* Class Actions
Expand All @@ -73,9 +78,11 @@ public static function graphql_register_types() {
// Enumerations.
Backorders::register();
Catalog_Visibility::register();
Customer_Connection_Orderby_Enum::register();
Discount_Type::register();
Manage_Stock::register();
Order_Status::register();
Product_Types::register();
Stock_Status::register();
Tax_Class::register();
Tax_Status::register();
Expand All @@ -100,6 +107,7 @@ public static function graphql_register_types() {
Customer_Address_Type::register();
Tax_Rate_Type::register();
Shipping_Method_Type::register();
Cart_Type::register();

// Connections.
Posts::register_connections();
Expand All @@ -113,5 +121,6 @@ public static function graphql_register_types() {
Customers::register_connections();
Tax_Rates::register_connections();
Shipping_Methods::register_connections();
Cart_Items::register_connections();
}
}
62 changes: 62 additions & 0 deletions src/connection/class-cart-items.php
@@ -0,0 +1,62 @@
<?php
/**
* Connection - Cart_Items
*
* Registers connections to CartItem
*
* @package WPGraphQL\Extensions\WooCommerce\Connection
* @since 0.0.3
*/

namespace WPGraphQL\Extensions\WooCommerce\Connection;

use WPGraphQL\Extensions\WooCommerce\Data\Factory;

/**
* Class - Cart_Items
*/
class Cart_Items {
/**
* Registers the various connections from other Types to CartItem
*/
public static function register_connections() {
// From Cart.
register_graphql_connection( self::get_connection_config() );
}

/**
* Given an array of $args, this returns the connection config, merging the provided args
* with the defaults
*
* @access public
* @param array $args - Connection configuration.
*
* @return array
*/
public static function get_connection_config( $args = [] ) {
$defaults = array(
'fromType' => 'Cart',
'toType' => 'CartItem',
'fromFieldName' => 'contents',
'connectionArgs' => self::get_connection_args(),
'resolve' => function ( $source, $args, $context, $info ) {
return Factory::resolve_cart_item_connection( $source, $args, $context, $info );
},
);
return array_merge( $defaults, $args );
}

/**
* Returns array of where args
*
* @return array
*/
public static function get_connection_args() {
return array(
'needShipping' => array(
'type' => 'Boolean',
'description' => __( 'Limit results to cart item that require shipping', 'wp-graphql-woocommerce' ),
),
);
}
}
10 changes: 10 additions & 0 deletions src/connection/class-coupons.php
Expand Up @@ -21,6 +21,16 @@ class Coupons extends WC_Connection {
public static function register_connections() {
// From RootQuery.
register_graphql_connection( self::get_connection_config() );

// From Cart.
register_graphql_connection(
self::get_connection_config(
array(
'fromType' => 'Cart',
'fromFieldName' => 'appliedCoupons',
)
)
);
}

/**
Expand Down
48 changes: 47 additions & 1 deletion src/connection/class-customers.php
Expand Up @@ -50,7 +50,7 @@ public static function register_connections() {
*/
public static function get_connection_config( $args ) {
$defaults = array(
'connectionArgs' => array(),
'connectionArgs' => self::get_connection_args(),
'resolveNode' => function( $id, $args, $context, $info ) {
return Factory::resolve_customer( $id, $context );
},
Expand All @@ -60,4 +60,50 @@ public static function get_connection_config( $args ) {
);
return array_merge( $defaults, $args );
}

/**
* Returns array of where args
*
* @return array
*/
public static function get_connection_args() {
return array(
'search' => array(
'type' => 'String',
'description' => __( 'Limit results to those matching a string.', 'wp-graphql-woocommerce' ),
),
'exclude' => array(
'type' => array( 'list_of' => 'Int' ),
'description' => __( 'Ensure result set excludes specific IDs.', 'wp-graphql-woocommerce' ),
),
'include' => array(
'type' => array( 'list_of' => 'Int' ),
'description' => __( 'Limit result set to specific ids.', 'wp-graphql-woocommerce' ),
),
'email' => array(
'type' => 'String',
'description' => __( 'Limit result set to resources with a specific email.', 'wp-graphql-woocommerce' ),
),
'role' => array(
'type' => 'UserRoleEnum',
'description' => __( 'Limit result set to resources with a specific role.', 'wp-graphql-woocommerce' ),
),
'roleIn' => array(
'type' => array( 'list_of' => 'UserRoleEnum' ),
'description' => __( 'Limit result set to resources with a specific group of roles.', 'wp-graphql-woocommerce' ),
),
'roleNotIn' => array(
'type' => array( 'list_of' => 'UserRoleEnum' ),
'description' => __( 'Limit result set to resources not within a specific group of roles.', 'wp-graphql-woocommerce' ),
),
'orderby' => array(
'type' => 'CustomerConnectionOrderbyEnum',
'description' => __( 'Order results by a specific field.', 'wp-graphql-woocommerce' ),
),
'order' => array(
'type' => 'OrderEnum',
'description' => __( 'Order of results.', 'wp-graphql-woocommerce' ),
),
);
}
}
12 changes: 8 additions & 4 deletions src/connection/class-orders.php
Expand Up @@ -66,15 +66,19 @@ public static function get_connection_args() {
return array_merge(
self::get_shared_connection_args(),
array(
'statuses' => array(
'type' => array( 'list_of' => 'String' ),
'statuses' => array(
'type' => array( 'list_of' => 'OrderStatusEnum' ),
'description' => __( 'Limit result set to orders assigned a specific status.', 'wp-graphql-woocommerce' ),
),
'customerId' => array(
'customerId' => array(
'type' => 'Int',
'description' => __( 'Limit result set to orders assigned a specific customer.', 'wp-graphql-woocommerce' ),
),
'productId' => array(
'customersIn' => array(
'type' => array( 'list_of' => 'Int' ),
'description' => __( 'Limit result set to orders assigned a specific group of customers.', 'wp-graphql-woocommerce' ),
),
'productId' => array(
'type' => 'Int',
'description' => __( 'Limit result set to orders assigned a specific product.', 'wp-graphql-woocommerce' ),
),
Expand Down
16 changes: 8 additions & 8 deletions src/connection/class-products.php
Expand Up @@ -145,15 +145,15 @@ public static function get_connection_args() {
'description' => __( 'Limit result set to products assigned a specific status.', 'wp-graphql-woocommerce' ),
),
'type' => array(
'type' => 'String',
'type' => 'ProductTypesEnum',
'description' => __( 'Limit result set to products assigned a specific type.', 'wp-graphql-woocommerce' ),
),
'typeIn' => array(
'type' => array( 'list_of' => 'String' ),
'type' => array( 'list_of' => 'ProductTypesEnum' ),
'description' => __( 'Limit result set to products assigned to a group of specific types.', 'wp-graphql-woocommerce' ),
),
'typeNotIn' => array(
'type' => array( 'list_of' => 'String' ),
'type' => array( 'list_of' => 'ProductTypesEnum' ),
'description' => __( 'Limit result set to products not assigned to a group of specific types.', 'wp-graphql-woocommerce' ),
),
'sku' => array(
Expand Down Expand Up @@ -224,20 +224,20 @@ public static function get_connection_args() {
'type' => 'String',
'description' => __( 'Limit result set to products with a specific attribute term ID (required an assigned attribute).', 'wp-graphql-woocommerce' ),
),
'inStock' => array(
'type' => 'Boolean',
'stockStatus' => array(
'type' => 'StockStatusEnum',
'description' => __( 'Limit result set to products in stock or out of stock.', 'wp-graphql-woocommerce' ),
),
'onSale' => array(
'type' => 'Boolean',
'description' => __( 'Limit result set to products on sale.', 'wp-graphql-woocommerce' ),
),
'minPrice' => array(
'type' => 'String',
'type' => 'Float',
'description' => __( 'Limit result set to products based on a minimum price.', 'wp-graphql-woocommerce' ),
),
'maxPrice' => array(
'type' => 'String',
'type' => 'Float',
'description' => __( 'Limit result set to products based on a maximum price.', 'wp-graphql-woocommerce' ),
),
'search' => array(
Expand All @@ -248,7 +248,7 @@ public static function get_connection_args() {

if ( wc_tax_enabled() ) {
$args['taxClass'] = array(
'type' => 'String',
'type' => 'TaxClassEnum',
'description' => __( 'Limit result set to products with a specific tax class.', 'wp-graphql-woocommerce' ),
);
}
Expand Down
19 changes: 17 additions & 2 deletions src/data/class-factory.php
Expand Up @@ -25,8 +25,7 @@
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Refund_Connection_Resolver;
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Tax_Rate_Connection_Resolver;
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Shipping_Method_Connection_Resolver;
use WPGraphQL\Extensions\WooCommerce\Data\Connection\WC_Posts_Connection_Resolver;
use WPGraphQL\Extensions\WooCommerce\Data\Connection\WC_Terms_Connection_Resolver;
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Cart_Item_Connection_Resolver;
use WPGraphQL\Extensions\WooCommerce\Model\Order_Item;
use WPGraphQL\Extensions\WooCommerce\Model\Tax_Rate;
use WPGraphQL\Extensions\WooCommerce\Model\Shipping_Method;
Expand Down Expand Up @@ -324,4 +323,20 @@ public static function resolve_shipping_method_connection( $source, array $args,
$resolver = new Shipping_Method_Connection_Resolver();
return $resolver->resolve( $source, $args, $context, $info );
}

/**
* Resolves CartItem connections
*
* @param mixed $source - Data resolver for connection source.
* @param array $args - Connection arguments.
* @param AppContext $context - AppContext object.
* @param ResolveInfo $info - ResolveInfo object.
*
* @return array
* @access public
*/
public static function resolve_cart_item_connection( $source, array $args, AppContext $context, ResolveInfo $info ) {
$resolver = new Cart_Item_Connection_Resolver();
return $resolver->resolve( $source, $args, $context, $info );
}
}

0 comments on commit 4781248

Please sign in to comment.