Skip to content

Instantly share code, notes, and snippets.

@voduytuan
Last active April 18, 2020 03:53
Show Gist options
  • Save voduytuan/97a9ea1da73623a359c25a52694245e0 to your computer and use it in GitHub Desktop.
Save voduytuan/97a9ea1da73623a359c25a52694245e0 to your computer and use it in GitHub Desktop.
Query Wave GraphQL to get `businesses` with mghoneimy/php-graphql-client
<?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());
}
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