{"id":29736950,"url":"https://github.com/mathsgod/array_to_gql","last_synced_at":"2026-05-19T10:34:35.920Z","repository":{"id":306355731,"uuid":"1025938147","full_name":"mathsgod/array_to_gql","owner":"mathsgod","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-25T05:30:27.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-25T07:35:03.035Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathsgod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-25T04:03:13.000Z","updated_at":"2025-07-25T05:28:39.000Z","dependencies_parsed_at":"2025-07-25T07:35:04.211Z","dependency_job_id":null,"html_url":"https://github.com/mathsgod/array_to_gql","commit_stats":null,"previous_names":["mathsgod/array_to_gql"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/mathsgod/array_to_gql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Farray_to_gql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Farray_to_gql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Farray_to_gql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Farray_to_gql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathsgod","download_url":"https://codeload.github.com/mathsgod/array_to_gql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathsgod%2Farray_to_gql/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266998946,"owners_count":24018958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-25T15:18:14.551Z","updated_at":"2026-05-19T10:34:35.915Z","avatar_url":"https://github.com/mathsgod.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Array to GraphQL\n\nA PHP library for converting PHP arrays to GraphQL query syntax.\n\n## Features\n\n- 🔧 **Basic Queries**: Support for simple field selection\n- 📊 **Nested Queries**: Support for multi-level nested array structures\n- 🎯 **Parameterized Queries**: Use `__args` to add query parameters\n- 🏷️ **Alias Queries**: Use `__aliasFor` to create GraphQL aliases\n- 🎨 **Object Parameters**: Support for complex nested object parameters\n- ✅ **Boolean Fields**: `true` values display as field selection, `false` values are ignored\n- 🎯 **Value Processing**: All non-`false` values (strings, numbers, `true`) only display key names, not values\n- 🔒 **Character Escaping**: Automatic handling of special character escaping\n\n## Installation\n\n```bash\ncomposer require mathsgod/array_to_gql\n```\n\n## Usage\n\n### Basic Usage\n\n```php\nrequire 'function.php';\n\n// Simple query - all non-false values only show key names\n$result = array_to_gql([\n    'user' =\u003e [\n        'id' =\u003e 1,           // Number value → only show key name\n        'name' =\u003e 'John',    // String value → only show key name\n        'email' =\u003e true,     // true value → show key name\n        'phone' =\u003e false     // false value → ignored\n    ]\n]);\n// Output: user { id name email }\n```\n\n### Value Processing Rules\n\n```php\n// Value processing rules example\n$result = array_to_gql([\n    'users' =\u003e [\n        'name' =\u003e [\n            'first' =\u003e 'John',    // String → only show first\n            'last' =\u003e 'Doe'       // String → only show last\n        ],\n        'age' =\u003e 25,              // Number → only show age\n        'active' =\u003e true,         // true → show active\n        'deleted' =\u003e false,       // false → completely ignored\n        'status' =\u003e 'online'      // String → only show status\n    ]\n]);\n// Output: users { name { first last } age active status }\n```\n\n### Parameterized Queries\n\n```php\n// Simple parameters\n$result = array_to_gql([\n    'users' =\u003e [\n        '__args' =\u003e [\n            'limit' =\u003e 10\n        ],\n        'id' =\u003e true,\n        'name' =\u003e true\n    ]\n]);\n// Output: users(limit: \"10\") { id name }\n\n// Object parameters\n$result = array_to_gql([\n    'users' =\u003e [\n        '__args' =\u003e [\n            'search' =\u003e [\n                'first_name' =\u003e 'John',\n                'last_name' =\u003e 'Doe'\n            ]\n        ],\n        'id' =\u003e true,\n        'name' =\u003e true\n    ]\n]);\n// Output: users(search: {first_name: \"John\", last_name: \"Doe\"}) { id name }\n```\n\n### Alias Queries\n\n```php\n$result = array_to_gql([\n    'allUsers' =\u003e [\n        '__aliasFor' =\u003e 'users',\n        '__args' =\u003e [\n            'status' =\u003e 'active'\n        ],\n        'id' =\u003e true,\n        'name' =\u003e true\n    ]\n]);\n// Output: allUsers: users(status: \"active\") { id name }\n```\n\n### Complex Nested Queries\n\n```php\n$result = array_to_gql([\n    'posts' =\u003e [\n        '__args' =\u003e [\n            'limit' =\u003e 10\n        ],\n        'id' =\u003e true,\n        'title' =\u003e true,\n        'author' =\u003e [\n            'name' =\u003e true,\n            'profile' =\u003e [\n                'bio' =\u003e true,\n                'avatar' =\u003e true\n            ]\n        ]\n    ]\n]);\n// Output: posts(limit: \"10\") { id title author { name profile { bio avatar } } }\n```\n\n## Running Tests\n\n```bash\n# Run all tests\nvendor/bin/phpunit\n\n# Run specific test file\nvendor/bin/phpunit tests/ArrayToGqlTest.php\n\n# Run tests with detailed output\nvendor/bin/phpunit --testdox\n```\n\n## Test Coverage\n\nCurrent tests cover:\n\n- ✅ Basic field selection\n- ✅ Nested array structures\n- ✅ Boolean value fields\n- ✅ Simple and complex parameters\n- ✅ Object parameters (multi-level nesting)\n- ✅ Alias functionality\n- ✅ Alias with parameter combinations\n- ✅ Special character escaping\n- ✅ Empty array handling\n- ✅ Mixed value types\n\n## API Reference\n\n### `array_to_gql($array): string`\n\nConverts a PHP array to a GraphQL query string.\n\n#### Special Keys\n\n- `__args`: Define query parameters\n- `__aliasFor`: Define field alias\n\n#### Parameters\n\n- `$array` (array): The PHP array to convert\n\n#### Return Value\n\n- `string`: GraphQL query string\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathsgod%2Farray_to_gql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathsgod%2Farray_to_gql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathsgod%2Farray_to_gql/lists"}