feat: add hour, minute, and second to DateInput for sub-day date filtering#3967
Merged
Conversation
…ering DateInput only exposed year, month, and day, so the before/after bounds of a dateQuery could constrain the calendar day but not the time of day, even though WP_Query's date_query supports hour/minute/second on before/after natively. Add hour, minute, and second (Int) to DateInput. This is purely additive on the GraphQL input side: the values pass straight through to WP_Query, so no resolver or query-cost change is needed. This is a non-breaking quick win toward the ideal shape (a DateTime scalar input, deferred to the filter/sort RFC). The three fields are optional and do not lock the schema into the decomposed shape, so a future DateTime-scalar input can supersede DateInput cleanly. Closes #1234
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3967 +/- ##
=======================================
Coverage 83.5% 83.6%
Complexity 5330 5330
=======================================
Files 286 286
Lines 22848 22866 +18
=======================================
+ Hits 19088 19106 +18
Misses 3760 3760
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
hour,minute, andsecond(Int) fields to theDateInputtype so adateQuery'sbefore/afterbounds can constrain the time of day, not just the calendar day.Why
DateInputonly exposedyear,month, andday. BecauseDateQueryInput.before/afterare typed asDateInput, clients could not narrow a query to a sub-day window, even thoughWP_Query'sdate_querysupportshour/minute/secondonbefore/afternatively. This is a long-standing, heavily requested ask (#1234).How
Purely additive on the GraphQL input side. The new fields pass straight through
Utils::map_inputintoWP_Query'sdate_query, so there is no resolver or query-cost change. The fields are optional, so existing queries are unaffected.This is a non-breaking quick win toward the eventual ideal (a proper
DateTimescalar input, deferred to the filter/sort RFC #1385). The decomposed fields stay optional and do not lock the schema in, so a futureDateTime-scalar input can supersedeDateInputcleanly.Test
Regression test in
PostObjectConnectionQueriesTest::testDateQueryAfterFiltersByHour: creates two posts on the same calendar day twelve hours apart, filters with anafterbound ofhour: 12, and asserts only the later post is returned. The test fails before the change (thehourfield is rejected by GraphQL validation) and passes after.Closes #1234