Hi,
Can I create a query in graphql, persisted, where I can ask for a date greater than if equal to today?
We have CFs that have dates that sometimes go older than today, and we want to filter them out in a graphQL query.
Is this possible?
Thanks
Joel
Solved! Go to Solution.
Meant to reply. Yes took some digging. Got this to work
lastDate: {
_logOp: OR
_expressions: [{
_operator: AT_OR_AFTER
value: $today
},
{
_operator: AT
value: null
},
]
}
I see docs on graphql that talk about using resolvers to provide better queries.
https://graphql.org/learn/execution/
I don't think graphql is the best for our purposes. I am considering a totally different DB that provides SQL, Non-relational, or querying the JCR directly from Java.
Problem is we want part of the query to be specified from auth/dialog. JCR query may be the way to go.
So in auth they would specify (for ex) Event name, startDate, which would be stored in content fragments, and we want to query Events starting after today.
Suggestions welcome.
I think you should be able to use the date filter. Are there any challenges which you are facing ?
Assuming you have a content fragment that has a field eventDate of type Calendar, you should be able to create a query to filter on that. Something like :
query eventByDate($eventStartDate: Date) {
eventList(
filter: {eventDate: {_expressions: [{value: $eventStartDate, _operator: AFTER}]}}
) {
items {
eventDate
}
}
}
And while calling this, just pass today's date
{"eventStartDate": "2023-06-19"}
Hope this helps
Meant to reply. Yes took some digging. Got this to work
lastDate: {
_logOp: OR
_expressions: [{
_operator: AT_OR_AFTER
value: $today
},
{
_operator: AT
value: null
},
]
}