get( OrdersTableDataStore::class ); $tables = $order_datastore::get_all_table_names_with_id(); // apply the after cursor to the query. if ( ! empty( $args['graphql_after_cursor'] ) ) { $after_cursor = new Cursor\COT_Cursor( $args, $query, 'after' ); $clauses['where'] .= $after_cursor->get_where(); } // apply the before cursor to the query. if ( ! empty( $args['graphql_before_cursor'] ) ) { $before_cursor = new Cursor\COT_Cursor( $args, $query, 'before' ); $clauses['where'] .= $before_cursor->get_where(); } // If the cursor "graphql_cursor_compare" arg is not in the query, // default to using ID DESC as the stabilizer. $orderby = ! empty( $clauses['orderby'] ) && is_string( $clauses['orderby'] ) ? $clauses['orderby'] . ',' : ''; if ( ! isset( $args['graphql_cursor_compare'] ) ) { $clauses['orderby'] = "{$orderby} {$tables['orders']}.id DESC "; } else { // Check the cursor compare order. $order = '>' === $args['graphql_cursor_compare'] ? 'ASC' : 'DESC'; $clauses['orderby'] = "{$orderby} {$tables['orders']}.id {$order} "; } return $clauses; } }