ncrypthic / doctrine-graphql
Doctrine 到 GraphQL 适配器
2.0.0
2020-07-03 04:23 UTC
Requires
- doctrine/orm: ^2.6
- webonyx/graphql-php: ^0.13.4
Requires (Dev)
- phpunit/phpunit: ^8
- ramsey/uuid-doctrine: ^1.5
This package is auto-updated.
Last update: 2024-09-11 20:37:02 UTC
README
Doctrine ORM 到 PHP GraphQL 的桥梁。
工作原理
此库提供了一个 DoctrineGraphQL 构建类,通过遵循 命名约定 将所有 Doctrine 实体构建为 GraphQL 类型。
对于每个映射到 GraphQL 对象类型的实体类,它将创建基本的 GraphQL 查询和突变。
安装
composer require ncrypthic/doctrine-graphql
用法
use LLA\DoctrineGraphQL\DoctrineGraphQL; use GraphQL\Server\Helper; use GraphQL\Server\ServerConfig; /* @var EntityManager $em */ // Get Doctrine's entity manager $builder = new DoctrineGraphQL(); $builder ->buildTypes($em) ->buildQueries($em) ->buildMutations($em); $schema = $builder->toGraphQLSchema(); $config = ServerConfig::create(['schema'=>$schema]); $helper = new Helper(); $req = $helper->parseHttpRequest(); $res = is_array($req) ? $helper->executeBatch($config, $req) : $helper->executeOperation($config, $req);
查询
见 查询
突变
见 突变