• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

AxeWP / wp-graphql-rank-math / 10338697041

11 Aug 2024 09:29AM UTC coverage: 89.203% (-1.0%) from 90.23%
10338697041

push

github

web-flow
fix: compatibility with WooGraphQL product/variation types (#105)

* fix: woographql interfaces

* ci: fix env

* ci: fix method name

* tests: stub woographql test as reminder

* ci: try again

* chore: phpstan

* ci: try again

* ci: .

* ci: cleanup and try again

* .

* .

* ci: use release zip for woo

* .

* ci: use direct zip

* .

0 of 33 new or added lines in 3 files covered. (0.0%)

2586 of 2899 relevant lines covered (89.2%)

10.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Extensions/WPGraphQLWooCommerce/Type/WPObject/SeoObjects.php
1
<?php
2
/**
3
 * Registers the SEO objects for WPGraphQL for WooCommerce.
4
 *
5
 * @package WPGraphQL\RankMath\Extensions\WPGraphQLWooCommerce\Type\WPObject
6
 * @since @todo
7
 */
8

9
declare( strict_types = 1 );
10

11
namespace WPGraphQL\RankMath\Extensions\WPGraphQLWooCommerce\Type\WPObject;
12

13
use WPGraphQL\RankMath\Type\WPInterface\ContentNodeSeo;
14
use WPGraphQL\RankMath\Utils\Utils;
15
use WPGraphQL\RankMath\Vendor\AxeWP\GraphQL\Interfaces\Registrable;
16
use WPGraphQL\RankMath\Vendor\AxeWP\GraphQL\Traits\TypeNameTrait;
17
use WPGraphQL\WooCommerce\WP_GraphQL_WooCommerce;
18

19
/**
20
 * Class - SeoObjects
21
 */
22
class SeoObjects implements Registrable {
23
        use TypeNameTrait;
24

25
        /**
26
         * {@inheritDoc}
27
         */
28
        public static function init(): void {
NEW
29
                add_action( 'graphql_register_types', [ static::class, 'register' ] );
×
30
        }
31

32
        /**
33
         * Registers the SEO GraphQL objects to the schema.
34
         */
35
        public static function register(): void {
36
                // Set SEO field types for product children.
NEW
37
                $product_types = WP_GraphQL_WooCommerce::get_enabled_product_types();
×
38

NEW
39
                foreach ( $product_types as $graphql_type_name ) {
×
NEW
40
                        Utils::overload_graphql_field_type( $graphql_type_name, 'seo', 'RankMathProductObjectSeo' );
×
41
                }
42

43
                // Register the Product Variation SEO type and apply it to the Product Variation and children.
NEW
44
                $type_name_for_product_variation = 'RankMathProductVariationObjectSeo';
×
45

NEW
46
                register_graphql_object_type(
×
NEW
47
                        $type_name_for_product_variation,
×
NEW
48
                        [
×
NEW
49
                                'description'     => __( 'The product variation object SEO data', 'wp-graphql-rank-math' ),
×
NEW
50
                                'interfaces'      => [ ContentNodeSeo::get_type_name() ],
×
NEW
51
                                'fields'          => [],
×
NEW
52
                                'eagerlyLoadType' => true,
×
NEW
53
                        ]
×
NEW
54
                );
×
55

NEW
56
                $product_variations = array_merge(
×
NEW
57
                        [
×
NEW
58
                                'ProductVariation',
×
NEW
59
                        ],
×
NEW
60
                        WP_GraphQL_WooCommerce::get_enabled_product_variation_types(),
×
NEW
61
                );
×
62

NEW
63
                foreach ( $product_variations as $product_variation ) {
×
NEW
64
                        Utils::overload_graphql_field_type( $product_variation, 'seo', $type_name_for_product_variation );
×
65
                }
66
        }
67
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc