@@ -29,7 +29,7 @@ public static function register_fields() {
2929 register_graphql_fields (
3030 'RootQuery ' ,
3131 [
32- 'cart ' => [
32+ 'cart ' => [
3333 'type ' => 'Cart ' ,
3434 'args ' => [
3535 'recalculateTotals ' => [
@@ -52,7 +52,7 @@ public static function register_fields() {
5252 return $ cart ;
5353 },
5454 ],
55- 'cartItem ' => [
55+ 'cartItem ' => [
5656 'type ' => 'CartItem ' ,
5757 'args ' => [
5858 'key ' => [
@@ -69,7 +69,7 @@ public static function register_fields() {
6969 return $ item ;
7070 },
7171 ],
72- 'cartFee ' => [
72+ 'cartFee ' => [
7373 'type ' => 'CartFee ' ,
7474 'args ' => [
7575 'id ' => [
@@ -88,7 +88,7 @@ public static function register_fields() {
8888 return $ fees [ $ fee_id ];
8989 },
9090 ],
91- 'coupon ' => [
91+ 'coupon ' => [
9292 'type ' => 'Coupon ' ,
9393 'description ' => __ ( 'A coupon object ' , 'wp-graphql-woocommerce ' ),
9494 'args ' => [
@@ -146,7 +146,7 @@ public static function register_fields() {
146146 return Factory::resolve_crud_object ( $ coupon_id , $ context );
147147 },
148148 ],
149- 'customer ' => [
149+ 'customer ' => [
150150 'type ' => 'Customer ' ,
151151 'description ' => __ ( 'A customer object ' , 'wp-graphql-woocommerce ' ),
152152 'args ' => [
@@ -194,7 +194,7 @@ public static function register_fields() {
194194 return Factory::resolve_session_customer ();
195195 },
196196 ],
197- 'order ' => [
197+ 'order ' => [
198198 'type ' => 'Order ' ,
199199 'description ' => __ ( 'A order object ' , 'wp-graphql-woocommerce ' ),
200200 'args ' => [
@@ -272,7 +272,7 @@ public static function register_fields() {
272272 return Factory::resolve_crud_object ( $ order_id , $ context );
273273 },
274274 ],
275- 'productVariation ' => [
275+ 'productVariation ' => [
276276 'type ' => 'ProductVariation ' ,
277277 'description ' => __ ( 'A product variation object ' , 'wp-graphql-woocommerce ' ),
278278 'args ' => [
@@ -318,7 +318,7 @@ public static function register_fields() {
318318 return Factory::resolve_crud_object ( $ variation_id , $ context );
319319 },
320320 ],
321- 'refund ' => [
321+ 'refund ' => [
322322 'type ' => 'Refund ' ,
323323 'description ' => __ ( 'A refund object ' , 'wp-graphql-woocommerce ' ),
324324 'args ' => [
@@ -399,7 +399,7 @@ public static function register_fields() {
399399 return Factory::resolve_crud_object ( $ refund_id , $ context );
400400 },
401401 ],
402- 'shippingMethod ' => [
402+ 'shippingMethod ' => [
403403 'type ' => 'ShippingMethod ' ,
404404 'description ' => __ ( 'A shipping method object ' , 'wp-graphql-woocommerce ' ),
405405 'args ' => [
@@ -434,7 +434,7 @@ public static function register_fields() {
434434 return Factory::resolve_shipping_method ( $ method_id );
435435 },
436436 ],
437- 'taxRate ' => [
437+ 'taxRate ' => [
438438 'type ' => 'TaxRate ' ,
439439 'description ' => __ ( 'A tax rate object ' , 'wp-graphql-woocommerce ' ),
440440 'args ' => [
@@ -469,7 +469,17 @@ public static function register_fields() {
469469 return Factory::resolve_tax_rate ( $ rate_id , $ context );
470470 },
471471 ],
472- 'allowedCountries ' => [
472+ 'countries ' => [
473+ 'type ' => [ 'list_of ' => 'CountriesEnum ' ],
474+ 'description ' => __ ( 'Countries ' , 'wp-graphql-woocommerce ' ),
475+ 'resolve ' => static function () {
476+ $ wc_countries = new \WC_Countries ();
477+ $ countries = $ wc_countries ->get_countries ();
478+
479+ return array_keys ( $ countries );
480+ },
481+ ],
482+ 'allowedCountries ' => [
473483 'type ' => [ 'list_of ' => 'CountriesEnum ' ],
474484 'description ' => __ ( 'Countries that the store sells to ' , 'wp-graphql-woocommerce ' ),
475485 'resolve ' => static function () {
@@ -479,7 +489,7 @@ public static function register_fields() {
479489 return array_keys ( $ countries );
480490 },
481491 ],
482- 'allowedCountryStates ' => [
492+ 'countryStates ' => [
483493 'type ' => [ 'list_of ' => 'CountryState ' ],
484494 'args ' => [
485495 'country ' => [
@@ -535,10 +545,11 @@ public static function register_fields() {
535545 'RootQuery ' ,
536546 $ field_name ,
537547 [
538- 'type ' => $ type_name ,
548+ 'type ' => $ type_name ,
539549 /* translators: Product type slug */
540- 'description ' => sprintf ( __ ( 'A %s product object ' , 'wp-graphql-woocommerce ' ), $ type_key ),
541- 'args ' => [
550+ 'description ' => sprintf ( __ ( 'A %s product object ' , 'wp-graphql-woocommerce ' ), $ type_key ),
551+ 'deprecationReason ' => 'Use "product" instead. ' ,
552+ 'args ' => [
542553 'id ' => [
543554 'type ' => 'ID ' ,
544555 'description ' => sprintf (
@@ -552,7 +563,7 @@ public static function register_fields() {
552563 'description ' => __ ( 'Type of ID being used identify product ' , 'wp-graphql-woocommerce ' ),
553564 ],
554565 ],
555- 'resolve ' => static function ( $ source , array $ args , AppContext $ context , ResolveInfo $ info ) use ( $ type_key , $ unsupported_type_enabled ) {
566+ 'resolve ' => static function ( $ source , array $ args , AppContext $ context , ResolveInfo $ info ) use ( $ type_key , $ unsupported_type_enabled ) {
556567 $ id = isset ( $ args ['id ' ] ) ? $ args ['id ' ] : null ;
557568 $ id_type = isset ( $ args ['idType ' ] ) ? $ args ['idType ' ] : 'global_id ' ;
558569
0 commit comments