api-skeletons/zf-doctrine-graphql

此包已被废弃,不再维护。作者建议使用 api-skeletons/doctrine-orm-graphql 包。

使用 Hydrators 的 Doctrine GraphQL

3.0.0 2020-10-06 00:40 UTC

This package is auto-updated.

Last update: 2023-10-17 19:47:15 UTC


README

Build Status Coverage PHPStan Gitter Patreon Total Downloads

这个库使用 Doctrine 的原生相关对象遍历来提供实体的完整 GraphQL 查询以及所有相关字段和实体。实体元数据是内省的,因此对 Doctrine 数据驱动程序无关。数据通过 hydrators 收集,从而允许通过 hydrator 过滤器、策略和命名策略对每个字段进行完全控制。支持多个对象管理器。支持多个 hydrator 配置。与 GraphiQL 兼容。

提供了一系列过滤器,可以在查询的任何位置过滤集合。

Doctrine 提供了轻松遍历数据库的方法。考虑以下假设查询

$entity[where id = 5]
  ->getRelation()
    ->getField1()
    ->getField2()
    ->getManyToOne([where name like '%dev%'])
      ->getName()
      ->getField3()
  ->getOtherRelation()
    ->getField4()
    ->getField5()

并在 GraphQL 中实现,通过 hydrators 对每个字段进行精细控制

  { 
    entity (filter: { id: 5 }) { 
      relation { 
        field1 
        field2 
        manyToOne (filter: { name_contains: 'dev' }) { 
          name 
          field3 
        } 
      } otherRelation { 
        field4 
        field5 
      } 
    } 
  }

阅读文档