GraphQl Api modification

Good part of the day!
I need to get calls from freepbx, and I do this:
$query = “{
fetchAllCdrs(first: 10000, after: 0, orderby: date, startDate: "$date", endDate: "$date") {
cdrs {

    $response = Http::withToken($this->getAccessToken())
        ->post(config('free_pbx.url') . '/gql', [
            'query' => $query

The problem is that I can’t pass startDate and endDate in format (‘Y-m-d H:i:s’), and also i can’t filter by ‘outbound_cnum’ field in the query.
Maybe there is other way to get calls filtered by date (‘Y-m-d H:i:s’) and outbound_cnum?
Is there is a way to extend this api? in /admin/modules/cdr/Api/Gql/Cdr.php there is a function:
ublic function queryCallback() {
if($this->checkAllReadScope()) {
return function() {
return [
‘fetchAllCdrs’ => […],
‘fetchCdr’ => […],
//can i add here smth like ‘fetchCustomFilterCdr’ => [‘my logic here’]

  1. Passing StartDate and EndDate in Proper Format: It seems you’re having trouble passing the startDate and endDate parameters in the correct format (Y-m-d H:i:s). You can format these dates in PHP before constructing the query. Here’s how you can do it:
$date = date('Y-m-d H:i:s', strtotime($your_date_variable));

Replace $your_date_variable with your actual date variable.

f outbound_cnum is not available in the schema, you may need to extend the schema to include this field. This involves modifying the GraphQL schema definition on the server side.

In the Cdr.php file you mentioned, you can add a new resolver for fetchCustomFilterCdr , which would contain your custom logic for filtering CDRs.

‘fetchCustomFilterCdr’ => function ($root, array $args, $context, $info) {
// Your custom logic here to filter CDRs based on some criteria
// You can access $args to get any parameters passed to the query
// You can access $context to get any contextual information
// You can return the filtered CDRs
return $filteredCdrs;
Remember, extending the API involves server-side changes, so you need access to the server codebase to make these modifications.

Best regard
Danish Hafeez | QA Assistant

Good part of the day! @danishhafeez Thank you very much for response. I have already tried to implement this logic, but as soon as I deployed changes, there was a warning message on admin page.
Here is it:

I thought, I could ignore this warning, but when I try to execute old query (fetchAllCrcd), there is an error

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.