Ok, finally found out after a lonnnng search !
Here the answer, for the one, who'd like to see !
First of all, as javascript and php date are count in millisecond & second, need to convert the date picker acf to correct value.
/**
* Convert values of ACF core date time pickers from Y-m-d H:i:s to timestamp
* @param string $value unmodified value
* @param int $post_id post ID
* @param object $field field object
* @return string modified value
*/
function acf_save_as_timestamp( $value, $post_id, $field ) {
if( $value ) {
$value = strtotime( $value*1000 );
}
return $value;
}
add_filter( 'acf/update_value/type=date_time_picker', 'acf_save_as_timestamp', 10, 3 );
/**
* Convert values of ACF core date time pickers from timestamp to Y-m-d H:i:s
* @param string $value unmodified value
* @param int $post_id post ID
* @param object $field field object
* @return string modified value
*/
function acf_load_as_timestamp( $value, $post_id, $field ) {
if( $value ) {
$value = date( 'Y-m-d H:i:s', $value*1000 );
}
return $value;
}
add_filter( 'acf/load_value/type=date_time_picker', 'acf_load_as_timestamp', 10, 3 );
After that need to add your field to graphql_PostObjectsConnectionOrderbyEnum_values & graphql_post_object_connection_query_args:
add_filter( 'graphql_PostObjectsConnectionOrderbyEnum_values', function( $values ) {
$values['STARTEVENT'] = [
'value' => 'startevent',
'description' => __( 'The date of startevent on the post', 'wp-graphql' ),
];
return $values;
} );
add_filter( 'graphql_post_object_connection_query_args', function( $query_args, $source, $input ) {
if ( isset( $input['where']['orderby'] ) && is_array( $input['where']['orderby'] ) ) {
foreach( $input['where']['orderby'] as $orderby ) {
if ( ! isset( $orderby['field'] ) || 'startevent' !== $orderby['field'] ) {
continue;
}
$query_args['meta_key'] = 'startevent';
$query_args['orderby'] = 'meta_value_num';
$query_args['order'] = $orderby['order'];
}
}
return $query_args;
}, 10, 3);
Finally, your field will appear on the orderby (my field is the startevent)
Capture of result