1. Go to this page and download the library: Download mathsgod/array_to_gql library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mathsgod / array_to_gql example snippets
// Simple query - all non-false values only show key names
$result = array_to_gql([
'user' => [
'id' => 1, // Number value → only show key name
'name' => 'John', // String value → only show key name
'email' => true, // true value → show key name
'phone' => false // false value → ignored
]
]);
// Output: user { id name email }
// Value processing rules example
$result = array_to_gql([
'users' => [
'name' => [
'first' => 'John', // String → only show first
'last' => 'Doe' // String → only show last
],
'age' => 25, // Number → only show age
'active' => true, // true → show active
'deleted' => false, // false → completely ignored
'status' => 'online' // String → only show status
]
]);
// Output: users { name { first last } age active status }