Skip to content

Commit 4ab3634

Browse files
committed
fix: "Product" interface applied to all sub Product interfaces for more optimal schema shape
1 parent 594bc29 commit 4ab3634

10 files changed

+51
-48
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
"allow-plugins": {
4141
"johnpbloch/wordpress-core-installer": true,
4242
"dealerdirect/phpcodesniffer-composer-installer": true,
43-
"phpstan/extension-installer": true,
44-
"composer/installers": true
43+
"phpstan/extension-installer": true
4544
}
4645
},
4746
"autoload": {

composer.lock

Lines changed: 39 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/type/interface/class-downloadable-product.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function register_interface(): void {
2525
'DownloadableProduct',
2626
[
2727
'description' => __( 'A downloadable product.', 'wp-graphql-woocommerce' ),
28-
'interfaces' => [ 'Node' ],
28+
'interfaces' => [ 'Node', 'Product' ],
2929
'fields' => self::get_fields(),
3030
'resolveType' => [ Core::class, 'resolve_product_type' ],
3131
]
@@ -47,10 +47,6 @@ public static function get_fields() {
4747
'type' => [ 'non_null' => 'Int' ],
4848
'description' => __( 'Product or variation ID', 'wp-graphql-woocommerce' ),
4949
],
50-
'virtual' => [
51-
'type' => 'Boolean',
52-
'description' => __( 'Is product virtual?', 'wp-graphql-woocommerce' ),
53-
],
5450
'downloadExpiry' => [
5551
'type' => 'Int',
5652
'description' => __( 'Download expiry', 'wp-graphql-woocommerce' ),

includes/type/interface/class-inventoried-product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function register_interface(): void {
2525
'InventoriedProduct',
2626
[
2727
'description' => __( 'A product with stock information.', 'wp-graphql-woocommerce' ),
28-
'interfaces' => [ 'Node' ],
28+
'interfaces' => [ 'Node', 'Product' ],
2929
'fields' => self::get_fields(),
3030
'resolveType' => [ Core::class, 'resolve_product_type' ],
3131
]

includes/type/interface/class-product-union.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static function register_interface(): void {
2626
'ProductUnion',
2727
[
2828
'description' => __( 'Union between the product and product variation types', 'wp-graphql-woocommerce' ),
29-
'interfaces' => [ 'Node' ],
29+
'interfaces' => [ 'Node', 'Product' ],
3030
'fields' => self::get_fields(),
3131
'resolveType' => [ Core::class, 'resolve_product_type' ],
3232
]

includes/type/interface/class-product-with-attributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function register_interface(): void {
2828
'ProductWithAttributes',
2929
[
3030
'description' => __( 'Products with default attributes.', 'wp-graphql-woocommerce' ),
31-
'interfaces' => [ 'Node' ],
31+
'interfaces' => [ 'Node', 'Product' ],
3232
'fields' => self::get_fields(),
3333
'connections' => self::get_connections(),
3434
'resolveType' => [ Core::class, 'resolve_product_type' ],

includes/type/interface/class-product-with-dimensions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function register_interface(): void {
2525
'ProductWithDimensions',
2626
[
2727
'description' => __( 'A physical product.', 'wp-graphql-woocommerce' ),
28-
'interfaces' => [ 'Node' ],
28+
'interfaces' => [ 'Node', 'Product' ],
2929
'fields' => self::get_fields(),
3030
'resolveType' => [ Core::class, 'resolve_product_type' ],
3131
]

includes/type/interface/class-product-with-pricing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function register_interface(): void {
2525
'ProductWithPricing',
2626
[
2727
'description' => __( 'Products with pricing.', 'wp-graphql-woocommerce' ),
28-
'interfaces' => [ 'Node' ],
28+
'interfaces' => [ 'Node', 'Product' ],
2929
'fields' => self::get_fields(),
3030
'resolveType' => [ Core::class, 'resolve_product_type' ],
3131
]

includes/type/interface/class-product-with-variations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static function register_interface(): void {
2929
'ProductWithVariations',
3030
[
3131
'description' => __( 'A product with variations.', 'wp-graphql-woocommerce' ),
32-
'interfaces' => [ 'Node' ],
32+
'interfaces' => [ 'Node', 'Product' ],
3333
'fields' => self::get_fields(),
3434
'connections' => self::get_connections(),
3535
'resolveType' => [ Core::class, 'resolve_product_type' ],

includes/type/interface/class-product.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ public static function get_fields() {
201201
'type' => 'Boolean',
202202
'description' => __( 'Can product be purchased?', 'wp-graphql-woocommerce' ),
203203
],
204+
'virtual' => [
205+
'type' => 'Boolean',
206+
'description' => __( 'Is product virtual?', 'wp-graphql-woocommerce' ),
207+
],
204208
'metaData' => \WPGraphQL\WooCommerce\Type\WPObject\Meta_Data_Type::get_metadata_field_definition(),
205209
];
206210
}

0 commit comments

Comments
 (0)