Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Product and product attribute mutations #851

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions includes/class-core-schema-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public static function register_post_types( $args, $post_type ) {
$args['graphql_interfaces'] = [ 'ContentNode' ];
$args['graphql_register_root_field'] = false;
$args['graphql_register_root_connection'] = false;
$args['graphql_exclude_mutations'] = [ 'create', 'delete', 'update' ];
$args['graphql_resolve_type'] = static function ( $value ) {
$type_registry = \WPGraphQL::get_type_registry();
$possible_types = WooGraphQL::get_enabled_product_types();
Expand Down
46 changes: 32 additions & 14 deletions includes/class-type-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public function init() {
Type\WPInputObject\Collection_Stats_Query_Input::register();
Type\WPInputObject\Collection_Stats_Where_Args::register();
Type\WPInputObject\Product_Attribute_Filter_Input::register();
Type\WPInputObject\Product_Attributes_Input::register();
Type\WPInputObject\Product_Dimensions_Input::register();
Type\WPInputObject\Product_Download_Input::register();
Type\WPInputObject\Product_Image_Input::register();

/**
* Interfaces.
Expand Down Expand Up @@ -111,6 +115,8 @@ public function init() {
Type\WPObject\Payment_Token_Types::register();
Type\WPObject\Country_State_Type::register();
Type\WPObject\Collection_Stats_Type::register();
Type\WPObject\Product_Attribute_Object_Type::register();
Type\WPObject\Product_Attribute_Term_Object_Type::register();

/**
* Object fields.
Expand Down Expand Up @@ -148,32 +154,44 @@ public function init() {
/**
* Mutations.
*/
Mutation\Customer_Register::register_mutation();
Mutation\Customer_Update::register_mutation();
Mutation\Cart_Add_Fee::register_mutation();
Mutation\Cart_Add_Item::register_mutation();
Mutation\Cart_Add_Items::register_mutation();
Mutation\Cart_Update_Item_Quantities::register_mutation();
Mutation\Cart_Remove_Items::register_mutation();
Mutation\Cart_Restore_Items::register_mutation();
Mutation\Cart_Empty::register_mutation();
Mutation\Cart_Apply_Coupon::register_mutation();
Mutation\Cart_Empty::register_mutation();
Mutation\Cart_Fill::register_mutation();
Mutation\Cart_Remove_Items::register_mutation();
Mutation\Cart_Remove_Coupons::register_mutation();
Mutation\Cart_Add_Fee::register_mutation();
Mutation\Cart_Restore_Items::register_mutation();
Mutation\Cart_Update_Item_Quantities::register_mutation();
Mutation\Cart_Update_Shipping_Method::register_mutation();
Mutation\Cart_Fill::register_mutation();
Mutation\Checkout::register_mutation();
Mutation\Coupon_Create::register_mutation();
Mutation\Coupon_Update::register_mutation();
Mutation\Coupon_Delete::register_mutation();
Mutation\Customer_Register::register_mutation();
Mutation\Customer_Update::register_mutation();
Mutation\Order_Create::register_mutation();
Mutation\Order_Update::register_mutation();
Mutation\Order_Delete::register_mutation();
Mutation\Order_Delete_Items::register_mutation();
Mutation\Checkout::register_mutation();
Mutation\Payment_Method_Delete::register_mutation();
Mutation\Payment_Method_Set_Default::register_mutation();
Mutation\Product_Attribute_Create::register_mutation();
Mutation\Product_Attribute_Update::register_mutation();
Mutation\Product_Attribute_Delete::register_mutation();
Mutation\Product_Attribute_Term_Create::register_mutation();
Mutation\Product_Attribute_Term_Update::register_mutation();
Mutation\Product_Attribute_Term_Delete::register_mutation();
Mutation\Product_Create::register_mutation();
Mutation\Product_Update::register_mutation();
Mutation\Product_Delete::register_mutation();
Mutation\Product_Variation_Create::register_mutation();
Mutation\Product_Variation_Update::register_mutation();
Mutation\Product_Variation_Delete::register_mutation();
Mutation\Review_Write::register_mutation();
Mutation\Review_Update::register_mutation();
Mutation\Review_Delete_Restore::register_mutation();
Mutation\Coupon_Create::register_mutation();
Mutation\Coupon_Update::register_mutation();
Mutation\Coupon_Delete::register_mutation();
Mutation\Payment_Method_Delete::register_mutation();
Mutation\Payment_Method_Set_Default::register_mutation();
Mutation\Update_Session::register_mutation();
}
}
23 changes: 21 additions & 2 deletions includes/class-wp-graphql-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ private function includes() {
require $include_directory_path . 'data/mutation/class-coupon-mutation.php';
require $include_directory_path . 'data/mutation/class-customer-mutation.php';
require $include_directory_path . 'data/mutation/class-order-mutation.php';
require $include_directory_path . 'data/mutation/class-product-mutation.php';

// Include factory class file.
require $include_directory_path . 'data/class-factory.php';
Expand Down Expand Up @@ -282,6 +283,8 @@ private function includes() {
require $include_directory_path . 'type/object/class-payment-token-types.php';
require $include_directory_path . 'type/object/class-country-state-type.php';
require $include_directory_path . 'type/object/class-collection-stats-type.php';
require $include_directory_path . 'type/object/class-product-attribute-object-type.php';
require $include_directory_path . 'type/object/class-product-attribute-term-object-type.php';

// Include input type class files.
require $include_directory_path . 'type/input/class-cart-item-input.php';
Expand All @@ -300,6 +303,10 @@ private function includes() {
require $include_directory_path . 'type/input/class-collection-stats-query-input.php';
require $include_directory_path . 'type/input/class-collection-stats-where-args.php';
require $include_directory_path . 'type/input/class-product-attribute-filter-input.php';
require $include_directory_path . 'type/input/class-product-attributes-input.php';
require $include_directory_path . 'type/input/class-product-dimensions-input.php';
require $include_directory_path . 'type/input/class-product-download-input.php';
require $include_directory_path . 'type/input/class-product-image-input.php';

// Include mutation type class files.
require $include_directory_path . 'mutation/class-cart-add-fee.php';
Expand All @@ -323,11 +330,23 @@ private function includes() {
require $include_directory_path . 'mutation/class-order-delete-items.php';
require $include_directory_path . 'mutation/class-order-delete.php';
require $include_directory_path . 'mutation/class-order-update.php';
require $include_directory_path . 'mutation/class-payment-method-delete.php';
require $include_directory_path . 'mutation/class-payment-method-set-default.php';
require $include_directory_path . 'mutation/class-product-attribute-create.php';
require $include_directory_path . 'mutation/class-product-attribute-delete.php';
require $include_directory_path . 'mutation/class-product-attribute-term-create.php';
require $include_directory_path . 'mutation/class-product-attribute-term-delete.php';
require $include_directory_path . 'mutation/class-product-attribute-term-update.php';
require $include_directory_path . 'mutation/class-product-attribute-update.php';
require $include_directory_path . 'mutation/class-product-create.php';
require $include_directory_path . 'mutation/class-product-delete.php';
require $include_directory_path . 'mutation/class-product-update.php';
require $include_directory_path . 'mutation/class-product-variation-create.php';
require $include_directory_path . 'mutation/class-product-variation-delete.php';
require $include_directory_path . 'mutation/class-product-variation-update.php';
require $include_directory_path . 'mutation/class-review-write.php';
require $include_directory_path . 'mutation/class-review-delete-restore.php';
require $include_directory_path . 'mutation/class-review-update.php';
require $include_directory_path . 'mutation/class-payment-method-delete.php';
require $include_directory_path . 'mutation/class-payment-method-set-default.php';
require $include_directory_path . 'mutation/class-update-session.php';

// Include connection class/function files.
Expand Down
Loading
Loading