studioespresso / craft-date-range

Date range field for Craft CMS
MIT License
12 stars 6 forks source link

Fix GraphQL query arguments for entries #39

Closed yoannisj closed 3 days ago

yoannisj commented 4 days ago

This PR addresses some issues with the GraphQL API.

  1. Fix error thrown when querying entries based on a Date Range field, via the following Query argument methods:
    • studioespresso\daterange\behaviors\EntryQueryBehaviour::isFuture()`
    • studioespresso\daterange\behaviors\EntryQueryBehaviour::isPast()`
    • studioespresso\daterange\behaviors\EntryQueryBehaviour::isNotPast()`
    • studioespresso\daterange\behaviors\EntryQueryBehaviour::isOngoing()`

When used in a GraphQL query, only 1 array argument is given to those methods, which was thowing an error in the Craft v5 version because the methods require 2 arguments (date range field handle and entryTypeHandle). This PR fixes this by making the 2nd argument optional, and extracts it from the 1st array argument instead. Fixes #38

  1. Fix typo in the isOngoing field on the GraphQL data type returned for Date Range fields.

Note: We are using our fork with the fixes above on one of our projects, and so far it is working well :).

janhenckens commented 3 days ago

Thanks for this @yoannisj! Haven't been able to spend much time on this plugin for the Craft 5 release as we don't regularly use it at the office.

The PR looks good, I'll merge it and tag a new release - if you'd like you can then switch back to this version and test if it works the same in your project?

janhenckens commented 3 days ago

5.0.0-beta.3 is out with this fix!