commadore / graphql-qb
A php GraphQL Query Builder. Nice API. Readable queries.
Installs: 3 051
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 9
Open Issues: 2
Requires
- php: ^7.2
- webonyx/graphql-php: ^0.11|^0.12|^0.13
Requires (Dev)
- phpunit/phpunit: ^8
README
I have a use case where I need to mock this lib, so statics and traits aren't desirable
graphql-qb
A php GraphQL Query Builder. Nice API. Readable queries. Examples in Unit Tests.
Includes:
- Query / Mutation / Fragment
- Sorted Fields
- Mandatory Operation Object
- Add variables
- Add arguments
- Directives (Include / Skip)
- Sub query
TODO:
- Arguments in sub queries
<?php include_once 'vendor/autoload.php'; use Commadore\GraphQL\Operation; use Commadore\GraphQL\Query; $operation = new Operation(Query::KEYWORD, 'article'); $query1 = new Query('article', [ 'id' => 999, 'title' => 'Hello World', 'note' => 3.5, ], [ 'id', 'title', 'body', ]); $operation->fields(['article' => $query1]); echo $operation;
query article { article: article(id: 999, note: 3.5, title: "Hello World") { body id title } }