{"id":33108977,"url":"https://github.com/panvid/php-graphql-request-builder","last_synced_at":"2026-04-04T17:27:18.453Z","repository":{"id":51354460,"uuid":"144753994","full_name":"panvid/php-graphql-request-builder","owner":"panvid","description":"Creates a GraphQL request payload with simple objects","archived":false,"fork":false,"pushed_at":"2021-05-13T20:46:33.000Z","size":35,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-12T04:13:57.633Z","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/panvid.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}},"created_at":"2018-08-14T17:50:25.000Z","updated_at":"2024-10-02T16:14:18.000Z","dependencies_parsed_at":"2022-09-22T14:25:35.195Z","dependency_job_id":null,"html_url":"https://github.com/panvid/php-graphql-request-builder","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/panvid/php-graphql-request-builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panvid%2Fphp-graphql-request-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panvid%2Fphp-graphql-request-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panvid%2Fphp-graphql-request-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panvid%2Fphp-graphql-request-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/panvid","download_url":"https://codeload.github.com/panvid/php-graphql-request-builder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panvid%2Fphp-graphql-request-builder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30949561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-26T02:38:33.265Z","status":"ssl_error","status_checked_at":"2026-03-26T02:36:10.435Z","response_time":114,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-11-15T01:00:22.737Z","updated_at":"2026-04-04T17:27:18.446Z","avatar_url":"https://github.com/panvid.png","language":"PHP","readme":"# GraphQL Request Builder\n[![Latest Stable Version](https://poser.pugx.org/dpauli/graphql-request-builder/v)](//packagist.org/packages/dpauli/graphql-request-builder)\n[![Total Downloads](https://poser.pugx.org/dpauli/graphql-request-builder/downloads)](//packagist.org/packages/dpauli/graphql-request-builder)\n[![License](https://poser.pugx.org/dpauli/graphql-request-builder/license)](//packagist.org/packages/dpauli/graphql-request-builder)\n[![UnitTests](https://github.com/dpauli/php-graphql-request-builder/actions/workflows/phpunit.yml/badge.svg)](//github.com/dpauli/php-graphql-request-builder/actions/workflows/phpunit.yml)\n\nThis library builds a request for sending to a GraphQL server.\n\n## What is GraphQL?\n*GraphQL* is a query language to easy request data from remote web servers. There are several pros for using *GraphQL*\ninstead of *REST* like\n\n- decreasing request amount\n- saving traffic in payload\n- avoid backend changes on changing client requested data\n\nFor a full description see [How to GraphQL](https://www.howtographql.com/).\n\n### Naming conventions\nThe schema of *GraphQL* is defined by two easy attributes:\n\n- *Type*s\n- *Argument*s\n\n*Type* define a structured requested data object. *Argument*s can define these types.\n\n#### Example\nA type *forum* can have *posts*, which has *authors* and a *title*. If you want to receive all *author* ant post *title*\ninformation as response your request can look like this:\n\n```graphql\n{\n  forum {\n    posts {\n      authors,\n      title\n    }\n  }\n}\n```\n\nTo specify your requested data for crawling only the **last 5** *posts* you can modify your request like this:\n\n```graphql\n{\n  forum {\n    posts(last: 5) {\n      authors,\n      title\n    }\n  }\n}\n```\n\n*GraphQL* requested data can complex as you want:\n\n```graphql\n{\n  forum {\n    posts(last: 5) {\n      authors(registration: {date: \"2019-08-08\"}, visible: true) {\n        surname,\n        prename(startingWith: \"a\"),\n        birthday\n      },\n      title\n    },\n    users(last: 10, sort: \"registrationDate\", order: \"DESC\")\n  }\n}\n```\n\n## Why this library?\nThis library helps building this **payload structure** without any `string` concatenation or other strange ideas.\n\n### Example\nTo create following request payload\n```graphql\n{\n  field {\n    search(criteria: {start: \"2019-08-23\"}) {\n      errors {\n        code\n        type\n        description\n      }\n      id\n    }\n  }\n}\n```\n\nyou need to execute following PHP code\n```php\n\u003c?php\ndeclare(strict_types=1);\n\nuse GraphQL\\RequestBuilder\\Argument;\nuse GraphQL\\RequestBuilder\\RootType;\nuse GraphQL\\RequestBuilder\\Type;\n\n$searchType = (new Type('search'))\n    -\u003eaddArgument(new Argument('criteria', new Argument('start', '2019-08-23')))\n    -\u003eaddSubTypes([\n        (new Type('errors'))-\u003eaddSubTypes(['code', 'type', 'description']),\n        'id'\n    ]\n);\n\necho (string) (new RootType('field'))-\u003eaddSubType($searchType);\n```\n\n## Build complex types\n\nIts also possible to build complex types. This code examples show you how to do this.\n\n### Arguments with array of arguments\n\nSometimes you want to have arrays with complex `Argument` types, like the following example.\n\n```graphql\n{\n  persons: [\n    {age: 30},\n    {age: 20},\n    {age: 12}\n  ]\n}\n``` \n\nFor this concept you can use the class `ArrayArgument` which give the possibility to add `Argument`s to an array.\n\n```php\n\u003c?php\ndeclare(strict_types=1);\n\nuse GraphQL\\RequestBuilder\\Argument;\nuse GraphQL\\RequestBuilder\\ArrayArgument;\n\n$persons = new ArrayArgument(\n    'persons',\n    [new Argument('age', 30), new Argument('age', 20), new Argument('age', 12)]\n);\n```\n\n### Arrays with more than one Argument in value.\n\nThe example above works if you have an `array` with only one `Argument`: every *person* only has one `Argument`, the\n*age*. If you want to have more `Argument`s you need to create an `Argument`with an empty name. \n\n```graphql\n{\n  persons: [\n    {\n      name: \"Hans\",\n      age: 30\n    },\n    {\n      name: \"Max\",\n      age: 20\n    }\n  ]\n}\n```\n\nYour *PHP* code should look like this:\n\n```php\n\u003c?php\ndeclare(strict_types=1);\n\nuse GraphQL\\RequestBuilder\\Argument;\nuse GraphQL\\RequestBuilder\\ArrayArgument;\n\n$person1 = new ArrayArgument('', [new Argument('name', 'Hans'), new Argument('age', 30)]);\n$person2 = new ArrayArgument('', [new Argument('name', 'Max'), new Argument('age', 20)]);\n\n$persons = new ArrayArgument('persons', [$person1, $person2]);\n```\n\n### Enum arguments\nTo create enum arguments it should look like this:\n\n```php\n\u003c?php\ndeclare(strict_types=1);\n\nuse GraphQL\\RequestBuilder\\EnumArgument;\n\n$person1 = new EnumArgument('EnumAttribute', 'EnumValue');\n```\n","funding_links":[],"categories":["Implementations"],"sub_categories":["PHP"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanvid%2Fphp-graphql-request-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpanvid%2Fphp-graphql-request-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanvid%2Fphp-graphql-request-builder/lists"}