fnash / graphql-qb
一个PHP GraphQL查询构建器。优秀的API。可读性强的查询。
v1.2
2020-12-04 22:31 UTC
Requires
- php: >7
- webonyx/graphql-php: ^0.11|^0.12|^0.13|^14.0
Requires (Dev)
- phpunit/phpunit: ^6.4
- symfony/var-dumper: *
This package is auto-updated.
Last update: 2024-09-05 07:02:54 UTC
README
graphql-qb
一个PHP GraphQL查询构建器。优秀的API。可读性强的查询。单元测试中的示例。
包含
- 查询 / 修改 / 片段
- 排序字段
- 自定义操作名称
- 如果您未指定操作名称并添加变量,将生成一个可预测的操作名称
- 添加变量
- 添加参数
- 指令(包含 / 跳过)
- 子查询
待办事项
- 子查询中的参数
<?php include_once 'vendor/autoload.php'; use Fnash\GraphQL\Query; $query = Query::create('article') ->variables([ '$withTags' => 'Boolean = false', ]) ->fields([ 'id', 'title', 'body', 'myLanguageAlias' => 'language', 'tags' => Query::create()->fields([ 'id', 'tagLabel' => 'label', 'language', 'taxonomy' => Query::create()->fields([ 'id', 'label', 'language' ]), ]) ]) ->includeIf([ 'tags' => '$withTags' ]) ; echo $query;
query query_d084b5fa08a495bb76e87b51cb5e2b33fc87039a($withTags: Boolean = false) { article { body id myLanguageAlias: language tags @include(if: $withTags) { id language tagLabel: label taxonomy { id label language } } title } }