Last active
April 18, 2020 03:53
-
-
Save voduytuan/97a9ea1da73623a359c25a52694245e0 to your computer and use it in GitHub Desktop.
Query Wave GraphQL to get `businesses` with mghoneimy/php-graphql-client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use GraphQL\Client; | |
use GraphQL\Query; | |
$endpoint = 'https://gql.waveapps.com/graphql/public'; | |
$client = new Client($endpoint, [ | |
'Authorization' => 'Bearer <<FULL_ACCESS_TOKEN_FROM_WAVEAPPS>>' | |
]); | |
$gql = (new Query('businesses')) | |
->setArguments([ | |
'page' => 1, | |
'pageSize' => 2 | |
]) | |
->setSelectionSet([ | |
(new Query('pageInfo')) | |
->setSelectionSet([ | |
'currentPage', | |
'totalPages', | |
'totalCount' | |
]), | |
(new Query('edges')) | |
->setSelectionSet([ | |
(new Query('node')) | |
->setSelectionSet([ | |
'id', | |
'name', | |
'isClassicAccounting', | |
'isClassicInvoicing', | |
'isPersonal' | |
]) | |
]) | |
] | |
); | |
try { | |
$results = $client->runQuery($gql, true); | |
$data = $results->getData(); | |
print_r($data); | |
} catch (\Exception $e) { | |
die('Error while query qraphql server.' . $e->getMessage()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[businesses] => Array | |
( | |
[pageInfo] => Array | |
( | |
[currentPage] => 1 | |
[totalPages] => 1 | |
[totalCount] => 2 | |
) | |
[edges] => Array | |
( | |
[0] => Array | |
( | |
[node] => Array | |
( | |
[id] => ErmzaW5lc3M6OGnnmhsjNzgtMjgzZi980zkxLThkMmUtNjc1NWVmNjgyyy32 | |
[name] => CropCom | |
[isClassicAccounting] => | |
[isClassicInvoicing] => | |
[isPersonal] => | |
) | |
) | |
[1] => Array | |
( | |
[node] => Array | |
( | |
[id] => Q857395lc3M6Mjh443JjNGItM2Yz872927DIyLTk0OGEtNjJiZjAzZGE5MmKH | |
[name] => Personal | |
[isClassicAccounting] => | |
[isClassicInvoicing] => | |
[isPersonal] => 1 | |
) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment