commadore/graphql-qb

PHP GraphQL 查询构建器。优秀的API。易于阅读的查询。

v3.2.0 2020-01-09 11:11 UTC

This package is auto-updated.

Last update: 2024-09-09 21:58:08 UTC


README

我在一个场景中需要模拟这个库,所以静态方法和特性不是我所希望的

graphql-qb

PHP GraphQL 查询构建器。优秀的API。易于阅读的查询。单元测试中有示例。

包含

  • 查询 / 变更 / 片段
  • 排序字段
  • 强制操作对象
  • 添加变量
  • 添加参数
  • 指令(包含 / 跳过)
  • 子查询

待办事项

  • 子查询中的参数
<?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
  }
}