2017 © Pedro Peláez
 

library doctrine-graphql

A GraphQL Doctrine ORM bridge

image

ratehub/doctrine-graphql

A GraphQL Doctrine ORM bridge

  • Friday, July 13, 2018
  • by voziv
  • Repository
  • 14 Watchers
  • 1 Stars
  • 1,021 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 81 % Grown

The README.md

doctrine-graphql

Build Status Total Downloads Latest Stable Version License, (*1)

Generates all the necessary types, queries and mutators using the Doctrine model metadata. All standard data fetching uses the doctrine Array Hydrator. This provider will handle the Object hydration once all queries are finished and the data is ready to be returned., (*2)

Features

Whitelist/Blacklist

The provider can be setup to filter what objects and properties are included in the final graphql api. * Whitelisting will only include types/properties that are marked for inclusion * Blacklisting will only include types/properties that are not marked for exclusion, (*3)

Authorization

An authorization provider can be implemented to limit access to types and fields via cred level permissions, (*4)

Naming Overrides

Names and descriptions of types and methods can be overwritten via the GraphQLType and GraphQLProperty annotations. Field Names are not yet able to be overwritten., (*5)

Deferred Loading

Associations take advantage of deferred loading via the DeferredBuffer. This is used to significantly reduce the number of queries and solves the N+1 problem when loading data (https://secure.phabricator.com/book/phabcontrib/article/n_plus_one/), (*6)

Custom Resolvers

Any property can have it's own custom resolver instead of the standard one provided by the provider., (*7)

Pagination

The provider supports key and offset pagination for top level queries. Also supports limiting results returned in an n-to-Many relationship., (*8)

Sorting

A queries results can be sorted by one or more fields in either ascending or descending order., (*9)

Query Filters for Types

Core types such as Strings, DateTime, Int, and BigInt support filters such as, (*10)

equals, in, less, greater, lessOrEqual, greaterOrEqual, between, (*11)

Polymorphic Entities

Provider supports querying polymorphic entities and querying unique fields per type using the GraphQL inline fragments., (*12)

Getting Started

After initializing doctrine you'll need to register the graphql annotations:, (*13)

```php use RateHub\GraphQL\Doctrine\AnnotationLoader; use Doctrine\Common\Annotations\AnnotationRegistry;, (*14)

AnnotationRegistry::registerLoader(array(new AnnotationLoader(), "load")); ```, (*15)

The next step is to initialize the graphql schema:, (*16)

```php use RateHub\GraphQL\Doctrine\DoctrineProvider; use RateHub\GraphQL\Doctrine\DoctrineProviderOptions; use RateHub\GraphQL\GraphContext; use GraphQL\Type\Definition\ObjectType; use GraphQL\Schema;, (*17)

// Set the options including any extensions $options = new DoctrineProviderOptions(); $options->em = $em; // EntityManager initialized within your as app as needed $options->filter = 'blacklist', (*18)

// Initialize the Provider. With blacklist filtering, no // annotations are needed unless something needs to be // excluded. The provider will generate all queries, // mutators and types needed. $provider = new DoctrineProvider('default', $options);, (*19)

// Initialize top level types $context = new GraphContext(); $queryType = new ObjectType('query', $provider->getQueries()); $mutatorType = new ObjectType('mutator', $provider->getMutators());, (*20)

// Initialize the schema $schema = new Schema([ 'query' => $queryType, 'mutation' => $mutatorType, 'types' => $provider->getTypes() ]);, (*21)

```, (*22)

From here you can execute a query:, (*23)

php $result = \GraphQL\GraphQL::execute( $schema, $params['query'], // Request parameter containing the graphql query null, $context, null );, (*24)

The Versions

13/07 2018

dev-dev-0.1

dev-dev-0.1

A GraphQL Doctrine ORM bridge

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nathanael Morrison

orm database doctrine data mapper graphql

06/02 2018

dev-master

9999999-dev

A GraphQL Doctrine ORM bridge

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nathanael Morrison

orm database doctrine data mapper graphql