-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Querying events by endDateQuery{ before } returns empty. #19
Comments
Hi @justlevine, @kidunot89 has provided an update we haven't merged yet. It appears to solve this problem. Please try with this branch: https://github.com/simplur/ql-events/tree/bugfix/wp-graphql-v0.4.0-and-woographql-v0.3.0-support. Thanks, |
No dice with that branch (which btw says it was merged ). I'm thinking this is a bug with TEC, since it's not just that startDateQuery works in GQL, but using an array for |
Seems to be a known quirk with TEC (https://wordpress.org/support/topic/bug-using-wp_query-to-get-past-events-doesnt-work-if-post_type-is-an-array/#post-13737078) and their recommendation for personal use is to use tribe's ORM. |
I was able to get data with the latest TEC plugins, the 1.0 version of WPGraphQL, and QL-Events. It does fail with older versions of each.
And yes, @kidunot89 merged this in a couple hours ago. |
TEC v5.3.0 and redownloading QL-Events did fix it. Closing (and thanks!) |
Thanks for testing this, @justlevine. It does seem to be an issue with TEC, though, correct? As such, we will need them to fix that. |
Well two separate issues. That WP_Query won't work with an array of post_types and the meta query as _EventEndDate is a TEC issue that their solution seems to be using their ORM instead (feel free to chime in here: https://wordpress.org/support/topic/bug-using-wp_query-to-get-past-events-doesnt-work-if-post_type-is-an-array/#post-13737078). That |
PS: the source for why the latest master of QL-Events is returning future events is because When uncommented, its back to returning empty because of the TEC bug. |
I'm not comfortable enough with this codebase to submit a PR, but so far adding the following code to if( ! empty( $query_args['endDateQuery'] ) && [ 'tribe_events' ] === $query_args[ 'post_type' ] ) {
$query_args[ 'post_type' ] = 'tribe_events';
} The full function would look like this now: public static function get_query_args( $query_args, $source, $args, $context, $info ) {
/**
* Collect the input_fields and sanitize them to prepare them for sending to the WP_Query
*/
$input_fields = [];
if ( ! empty( $args['where'] ) ) {
$input_fields = self::sanitize_input_fields( $args['where'] );
}
/**
* Merge the input_fields with the default query_args
*/
if ( ! empty( $input_fields ) ) {
$query_args = array_merge( $query_args, $input_fields );
/**
* If using endDateQuery, make sure the post_type is a string.
*
* @see https://github.com/simplur/ql-events/issues/19
*/
if( ! empty( $query_args['endDateQuery'] ) && [ 'tribe_events' ] === $query_args[ 'post_type' ] ) {
$query_args[ 'post_type' ] = 'tribe_events';
}
}
return apply_filters(
'graphql_' . Main::POSTTYPE . '_connection_query_args',
$query_args,
$source,
$args,
$context,
$info
);
} (Note, I also uncommented the |
Trying to query past events, but its returning an empty array.
Query:
Response:
using
startDateQuery
works fine.Here's where it gets a bit weird: if I grab the query_args and do a WP_Query, it also doesn't work:
but if I change it to
post_type => 'tribe_events
instead of an array it does return the events.Not sure if this is an issue with TEC (that
post_type
should accept an array), or with ql-events (that it should be passing thepost_type
as a string).The text was updated successfully, but these errors were encountered: