I have applied filter for this "graphql_require_authentication_allowed_fields". It's from the official documentation for allowing login field from the authentication. But it's not working.
`add_action( 'do_graphql_request', 'force_graphql_api_authentication', 10, 1 );
function force_graphql_api_authentication( $query ) {
if ( ! defined( 'GRAPHQL_HTTP_REQUEST' ) || true !== GRAPHQL_HTTP_REQUEST ) {
return;
}
$introspection_query = \GraphQL\Type\Introspection::getIntrospectionQuery();
$is_introspection_query = trim($query) === trim($introspection_query);
if ( $is_introspection_query ) {
return;
}
if ( ! get_current_user_id() ) {
throw new \GraphQL\Error\UserError( __( 'You do not have permission to access the API', 'preachitgwl' ) );
}
}
add_filter(
'graphql_require_authentication_allowed_fields',
function( $allowed ) {
$allowed[] = 'login';
return $allowed;
}, 10, 1 );`