I am working to get response from dutchie GrapghQL api using PHP, These are working fine with POSTMAN , but when I am trying to get them work with below Library , its not working at all, and there is very less documentation available for dutchie(php graghql)
https://github.com/webonyx/graphql-php/
Before I have worked on rest apis with php MySQL, its totally new thing to me so not getting how get it work
<?php
include("library/graphQL/vendor/autoload.php");
use GraphQL\Client;
use GraphQL\Exception\QueryError;
$client = new Client(
'https://plus.dutchie.com/plus/2021-07/graphql',
["Authorization" => "public- eyJhbGciOiJIUzI1NiJ9."]
);
// Create the GraphQL mutation
$gql = (new Mutation('Ping'))
->setSelectionSet(
[
'id',
'time',
]
);
// Run query to get results
try {
$results = $client->runQuery($gql);
}
catch (QueryError $exception) {
// Catch query error and desplay error details
print_r($exception->getErrorDetails());
exit;
}
Display original response from endpoint
var_dump($results->getResponseObject());
Display part of the returned results of the object
var_dump($results->getData()->pokemon);
Reformat the results to an array and get the results of part of the array
$results->reformatResults(true);
print_r($results->getData()['data']);
Error I am getting
Fatal error: Uncaught Error: Class 'Mutation' not found in
C:\xampp\htdocs\dispoapi\index.php:21 Stack trace: #0 {main}
thrown in C:\xampp\htdocs\dispoapi\index.php on line 21