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

AxeWP / wp-graphql-headless-login / #72

07 Jun 2025 09:08AM UTC coverage: 82.559% (-0.4%) from 82.929%
#72

push

php-coveralls

web-flow
Merge a58b52098 into fe4ece4d0

121 of 163 new or added lines in 26 files covered. (74.23%)

10 existing lines in 8 files now uncovered.

2291 of 2775 relevant lines covered (82.56%)

24.03 hits per line

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

92.31
/src/Type/WPObject/AuthenticationData.php
1
<?php
2
/**
3
 * The Headless Login Authentication Data GraphQL object.
4
 *
5
 * @package WPGraphQL\Login\Type\WPObject
6
 */
7

8
declare( strict_types = 1 );
9

10
namespace WPGraphQL\Login\Type\WPObject;
11

12
use WPGraphQL\Login\Vendor\AxeWP\GraphQL\Abstracts\ObjectType;
13
use WPGraphQL\Login\Vendor\AxeWP\GraphQL\Helper\Compat;
14
use WPGraphQL\Model\User;
15

16
/**
17
 * Class - AuthenticationData
18
 */
19
class AuthenticationData extends ObjectType {
20
        /**
21
         * {@inheritDoc}
22
         */
23
        public static function register(): void {
24
                parent::register();
67✔
25

26
                /**
27
                 * Filters the GraphQL 'user' types which should have 'AuthenticationData' added to them.
28
                 *
29
                 * @param string[] $type_names The names of the GraphQL 'user' types. Defaults to 'User'
30
                 */
31
                $user_types = apply_filters( 'graphql_login_user_types', [ 'User' ] );
67✔
32

33
                foreach ( $user_types as $type ) {
67✔
34
                        register_graphql_field(
67✔
35
                                $type,
67✔
36
                                'auth',
67✔
37
                                // @todo remove Compat wrapper when WPGraphQL v2.3.0+ is required.
38
                                Compat::resolve_graphql_config(
67✔
39
                                        [
67✔
40
                                                'type'        => self::get_type_name(),
67✔
41
                                                'description' => static fn () => __( 'Headless Login authentication data.', 'wp-graphql-headless-login' ),
67✔
42
                                                'resolve'     => static function ( $source ) {
67✔
43
                                                        if ( ! $source instanceof User && isset( $source->ID ) ) {
28✔
NEW
44
                                                                $user = get_user_by( 'ID', $source->ID );
×
45

NEW
46
                                                                if ( $user instanceof \WP_User ) {
×
NEW
47
                                                                        return new User( $user );
×
48
                                                                }
49
                                                        }
50
                                                        return $source;
28✔
51
                                                },
67✔
52
                                        ]
67✔
53
                                )
67✔
54
                        );
67✔
55
                }
56
        }
57

58
        /**
59
         * {@inheritDoc}
60
         */
61
        public static function type_name(): string {
62
                return 'AuthenticationData';
67✔
63
        }
64

65
        /**
66
         * {@inheritDoc}
67
         */
68
        public static function get_description(): string {
UNCOV
69
                return __( 'The Headless Login authentication data.', 'wp-graphql-headless-login' );
×
70
        }
71

72
        /**
73
         * {@inheritDoc}
74
         */
75
        public static function get_fields(): array {
76
                return [
67✔
77
                        'authToken'              => [
67✔
78
                                'type'        => 'String',
67✔
79
                                'description' => static fn () => __( 'A new authentication token to use in future requests.', 'wp-graphql-headless-login' ),
67✔
80
                        ],
67✔
81
                        'authTokenExpiration'    => [
67✔
82
                                'type'        => 'String',
67✔
83
                                'description' => static fn () => __( 'The authentication token expiration timestamp.', 'wp-graphql-headless-login' ),
67✔
84
                        ],
67✔
85
                        'isUserSecretRevoked'    => [
67✔
86
                                'type'        => 'Boolean',
67✔
87
                                'description' => static fn () => __( 'Whether the user secret has been revoked.', 'wp-graphql-headless-login' ),
67✔
88
                        ],
67✔
89
                        'linkedIdentities'       => [
67✔
90
                                'type'        => [ 'list_of' => LinkedIdentity::get_type_name() ],
67✔
91
                                'description' => static fn () => __( 'A list of linked identities from the Headless Login provider.', 'wp-graphql-headless-login' ),
67✔
92
                        ],
67✔
93
                        'userSecret'             => [
67✔
94
                                'type'        => 'String',
67✔
95
                                'description' => static fn () => __( 'The user secret.', 'wp-graphql-headless-login' ),
67✔
96
                        ],
67✔
97
                        'refreshToken'           => [
67✔
98
                                'type'        => 'String',
67✔
99
                                'description' => static fn () => __( 'A new refresh token to use in future requests.', 'wp-graphql-headless-login' ),
67✔
100
                        ],
67✔
101
                        'refreshTokenExpiration' => [
67✔
102
                                'type'        => 'String',
67✔
103
                                'description' => static fn () => __( 'The refresh token expiration timestamp.', 'wp-graphql-headless-login' ),
67✔
104
                        ],
67✔
105
                ];
67✔
106
        }
107
}
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