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

wp-graphql / wp-graphql / 14716683875

28 Apr 2025 07:58PM UTC coverage: 84.287% (+1.6%) from 82.648%
14716683875

push

github

actions-user
release: merge develop into master for v2.3.0

15905 of 18870 relevant lines covered (84.29%)

257.23 hits per line

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

86.84
/src/Type/InterfaceType/Previewable.php
1
<?php
2

3
namespace WPGraphQL\Type\InterfaceType;
4

5
use WPGraphQL\Model\Post;
6
use WPGraphQL\Registry\TypeRegistry;
7

8
class Previewable {
9

10
        /**
11
         * Adds the Previewable Type to the WPGraphQL Registry
12
         *
13
         * @param \WPGraphQL\Registry\TypeRegistry $type_registry
14
         *
15
         * @throws \Exception
16
         */
17
        public static function register_type( TypeRegistry $type_registry ): void {
593✔
18
                register_graphql_interface_type(
593✔
19
                        'Previewable',
593✔
20
                        [
593✔
21
                                'description' => static function () {
593✔
22
                                        return __( 'Content that supports a draft preview mode. Allows viewing unpublished changes before they are made publicly available. Previewing unpublished changes requires appropriate permissions.', 'wp-graphql' );
18✔
23
                                },
593✔
24
                                'fields'      => static function () {
593✔
25
                                        return [
347✔
26
                                                'isPreview'                 => [
347✔
27
                                                        'type'        => 'Boolean',
347✔
28
                                                        'description' => static function () {
347✔
29
                                                                return __( 'Whether the object is a node in the preview state', 'wp-graphql' );
18✔
30
                                                        },
347✔
31
                                                ],
347✔
32
                                                'previewRevisionDatabaseId' => [
347✔
33
                                                        'type'        => 'Int',
347✔
34
                                                        'description' => static function () {
347✔
35
                                                                return __( 'The database id of the preview node', 'wp-graphql' );
18✔
36
                                                        },
347✔
37
                                                ],
347✔
38
                                                'previewRevisionId'         => [
347✔
39
                                                        'type'        => 'ID',
347✔
40
                                                        'description' => static function () {
347✔
41
                                                                return __( 'Whether the object is a node in the preview state', 'wp-graphql' );
18✔
42
                                                        },
347✔
43
                                                ],
347✔
44
                                        ];
347✔
45
                                },
593✔
46
                                'resolveType' => static function ( Post $post ) use ( $type_registry ) {
593✔
47
                                        $type = 'Post';
×
48

49
                                        $post_type_object = isset( $post->post_type ) ? get_post_type_object( $post->post_type ) : null;
×
50

51
                                        if ( isset( $post_type_object->graphql_single_name ) ) {
×
52
                                                $type = $type_registry->get_type( $post_type_object->graphql_single_name );
×
53
                                        }
54

55
                                        return $type;
×
56
                                },
593✔
57
                        ]
593✔
58
                );
593✔
59
        }
60
}
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

© 2025 Coveralls, Inc