diff --git a/.travis.yml b/.travis.yml index d0981f56b..bb38d5b38 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,11 +21,10 @@ matrix: - php: 7.0 env: SYMFONY_VERSION=3.0.* - php: 7.0 - env: SYMFONY_VERSION='3.1.*@dev' + env: SYMFONY_VERSION=3.1.* allow_failures: - php: nightly - - env: SYMFONY_VERSION='3.1.*@dev' cache: directories: diff --git a/Generator/TypeGenerator.php b/Generator/TypeGenerator.php index 958c63865..5226442ae 100644 --- a/Generator/TypeGenerator.php +++ b/Generator/TypeGenerator.php @@ -12,7 +12,6 @@ namespace Overblog\GraphQLBundle\Generator; use Overblog\GraphQLGenerator\Generator\TypeGenerator as BaseTypeGenerator; -use Symfony\Component\ClassLoader\ClassCollectionLoader; use Symfony\Component\ClassLoader\MapClassLoader; use Symfony\Component\Filesystem\Filesystem; @@ -150,7 +149,7 @@ function ($childrenComplexity, $args = []) { return $code; } - public function compile(array $configs) + public function compile(array $configs, $loadClasses = true) { $cacheDir = $this->getCacheDir(); if (file_exists($cacheDir)) { @@ -159,16 +158,10 @@ public function compile(array $configs) } $classes = $this->generateClasses($configs, $cacheDir, true); + file_put_contents($this->getClassesMap(), "getClassCollectionPath(); - - $mapClassLoader = new MapClassLoader($classes); - $mapClassLoader->register(); - - ClassCollectionLoader::load(array_keys($classes), dirname($file), basename($file, '.php.cache'), false, false, '.php.cache'); - - self::$classMapLoaded = true; + if ($loadClasses) { + $this->loadClasses(true); } return $classes; @@ -177,18 +170,17 @@ public function compile(array $configs) public function loadClasses($forceReload = false) { if (!self::$classMapLoaded || $forceReload) { - $classCollectionPath = $this->getClassCollectionPath(); + $classes = require $this->getClassesMap(); - if (file_exists($classCollectionPath)) { - require_once $classCollectionPath; - } + $mapClassLoader = new MapClassLoader($classes); + $mapClassLoader->register(); self::$classMapLoaded = true; } } - private function getClassCollectionPath() + private function getClassesMap() { - return $this->getCacheDir().'/__types.bootstrap.php.cache'; + return $this->getCacheDir().'/__classes.map'; } } diff --git a/README.md b/README.md index 9419ed852..8be822b97 100644 --- a/README.md +++ b/README.md @@ -266,7 +266,34 @@ Droid: ``` ### Union -TODO +```yaml +# src/MyBundle/Resources/config/graphql/HumanAndDroid.types.yml +# +# This implements the following type system shorthand: +# union HumanAndDroid = Human | Droid +HumanAndDroid: + type: union + config: + types: [Human, Droid] + description: Human and Droid +``` + +### Input object + +```yaml +# src/MyBundle/Resources/config/graphql/HumanAndDroid.types.yml +# +# This implements the following type system shorthand: +# type HeroInput { +# name: Episode! +# } +HeroInput: + type: input-object + config: + fields: + name: + type: "Episode!" +``` ### Schema