I'm working on wpgraphql2.1.0
with acf6 and WPGraphQL for ACF 2.4.1
and I need to get a content type named "evenement" (that we'll call events) that I filter based on their date.
The filtering part is done and works well, I get events based on the field date_de_debut
(translated to start_date) which are located in a repeater field dates
I got it working based on this tutorial
add_filter('graphql_post_object_connection_query_args', function ($query_args, $source, $args, $context, $info) {
if($args['where']['futur']) {
$date = date('Ymd');
$query_args['meta_query'] = [
[ // si une des deux condition est respectée
array(
'relation' => 'OR',
array( // if start_date in the future AND no end_date
'relation' => 'AND',
array(
'key' => 'dates_$_date_de_debut',
'value' => $date,
'compare' => '>=',
),
array(
'key' => 'dates_$_date_de_fin',
'compare' => 'NOT EXISTS',
),
),
array( // if start_date OR end_date in the future
'relation' => 'OR',
array(
'key' => 'dates_$_date_de_debut',
'compare' => '>=',
'value' => $date,
),
array(
'key' => 'dates_$_date_de_fin',
'compare' => '>=',
'value' => $date,
),
),
),
]
];
}
return $query_args;
}, 10, 5);
Now what I would like to do but struggle to get working is a way to duplicate each of my returned events based on their dates
in the repeater field
What I currently have :
{
"title": "Event1",
"fieldsEvenement": {
"dates": [
{
"dateDeDebut": "2025-03-20T00:00:00+00:00",
"dateDeFin": null,
},
{
"dateDeDebut": "2025-03-21T00:00:00+00:00",
"dateDeFin": "2025-03-26T00:00:00+00:00",
}
]
}
}
What I would like :
{
"title": "Event1",
"fieldsEvenement": {
"dates": [
{
"dateDeDebut": "2025-03-20T00:00:00+00:00",
"dateDeFin": null,
}
]
}
}
{
"title": "Event1",
"fieldsEvenement": {
"dates": [
{
"dateDeDebut": "2025-03-21T00:00:00+00:00",
"dateDeFin": "2025-03-26T00:00:00+00:00",
}
]
}
}