Skip to content

Commit c61a64b

Browse files
authored
Merge pull request #199 from kidunot89/bugfix/unsupported-product-types
Better handling of unsupported product types.
2 parents ddeedc3 + 47703da commit c61a64b

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

includes/connection/class-cart-items.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function register_connections() {
3333
*
3434
* @return array
3535
*/
36-
public static function get_connection_config( $args = [] ) {
36+
public static function get_connection_config( $args = array() ) {
3737
$defaults = array(
3838
'fromType' => 'Cart',
3939
'toType' => 'CartItem',

includes/connection/class-coupons.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function register_connections() {
4242
*
4343
* @return array
4444
*/
45-
public static function get_connection_config( $args = [] ) {
45+
public static function get_connection_config( $args = array() ) {
4646
$defaults = array(
4747
'fromType' => 'RootQuery',
4848
'toType' => 'Coupon',

includes/connection/class-orders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static function register_connections() {
4141
*
4242
* @return array
4343
*/
44-
public static function get_connection_config( $args = [] ) {
44+
public static function get_connection_config( $args = array() ) {
4545
$defaults = array(
4646
'fromType' => 'RootQuery',
4747
'toType' => 'Order',

includes/type/interface/class-product.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ public static function register_interface( &$type_registry ) {
3737
if ( isset( $possible_types[ $value->type ] ) ) {
3838
return $type_registry->get_type( $possible_types[ $value->type ] );
3939
}
40-
return null;
40+
throw new UserError(
41+
sprintf(
42+
/* translators: %s: Product type */
43+
__( 'The "%s" product type is not supported by the core WPGraphQL WooCommerce (WooGraphQL) schema.', 'wp-graphql-woocommerce' ),
44+
$value->type
45+
)
46+
);
4147
},
4248
)
4349
);

0 commit comments

Comments
 (0)