Skip to content

Commit 56bc31c

Browse files
committed
- WPGraphQL v0.6.0 regression
- Update so that the `Types::` static methods aren't being called for Type definitions
1 parent 2ebbc31 commit 56bc31c

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/ManageTokens.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
namespace WPGraphQL\JWT_Authentication;
1010

1111
use GraphQL\Error\UserError;
12-
use GraphQL\Type\Definition\Type;
13-
use WPGraphQL\Model\User;
14-
use WPGraphQL\Types;
1512

1613
/**
1714
* Class - ManageToken
@@ -25,7 +22,7 @@ public static function init() {
2522
add_action( 'graphql_register_types', [ __CLASS__, 'add_jwt_fields' ], 10 );
2623

2724
// Add fields to the input for user mutations.
28-
add_filter( 'graphql_user_mutation_input_fields', [ __CLASS__, 'add_user_mutation_input_fields' ] );
25+
add_action( 'graphql_register_types', [ __CLASS__, 'add_user_mutation_input_fields' ] );
2926
add_action( 'graphql_user_object_mutation_update_additional_data', [ __CLASS__, 'update_jwt_fields_during_mutation' ], 10, 3 );
3027

3128
// Filter the signed token, preventing it from returning if the user has had their JWT Secret revoked.
@@ -150,20 +147,24 @@ public static function register_jwt_fields_to( $type ) {
150147
/**
151148
* Given an array of fields, this returns an array with the new fields added
152149
*
153-
* @param array $fields The input fields for user mutations.
154-
*
155150
* @return array
156151
*/
157-
public static function add_user_mutation_input_fields( array $fields ) {
158-
$fields['revokeJwtUserSecret'] = [
159-
'type' => Types::boolean(),
160-
'description' => __( 'If true, this will revoke the users JWT secret. If false, this will unrevoke the JWT secret AND issue a new one. To revoke, the user must have proper capabilities to edit users JWT secrets.', 'wp-graphql-jwt-authentication' ),
161-
];
162-
$fields['refreshJwtUserSecret'] = [
163-
'type' => Types::boolean(),
164-
'description' => __( 'If true, this will refresh the users JWT secret.' ),
152+
public static function add_user_mutation_input_fields() {
153+
$fields = [
154+
'revokeJwtUserSecret' => [
155+
'type' => 'Boolean',
156+
'description' => __( 'If true, this will revoke the users JWT secret. If false, this will unrevoke the JWT secret AND issue a new one. To revoke, the user must have proper capabilities to edit users JWT secrets.', 'wp-graphql-jwt-authentication' ),
157+
],
158+
'refreshJwtUserSecret' => [
159+
'type' => 'Boolean',
160+
'description' => __( 'If true, this will refresh the users JWT secret.' ),
161+
],
165162
];
166163

164+
register_graphql_fields( 'RegisterUserInput', $fields );
165+
register_graphql_fields( 'CreateUserInput', $fields );
166+
register_graphql_fields( 'UpdateUserInput', $fields );
167+
167168
return $fields;
168169
}
169170

0 commit comments

Comments
 (0)