Exemplo n.º 1
0
 /**
  * @param InterfaceType $type
  * @return GQLDefinition\InterfaceType
  */
 private function createInterface(InterfaceType $type)
 {
     if (null !== $type->getFields()) {
         $this->prepareFields($type->getFields());
     }
     $type = new GQLDefinition\InterfaceType($type->toMapping());
     return $type;
 }
Exemplo n.º 2
0
 /**
  * @param InterfaceType $interface
  * @return GQLDefinition\InterfaceType
  */
 private function createInterface(InterfaceType $interface)
 {
     if (null !== $interface->getFields()) {
         $this->prepareFields($interface->getFields(), $interface);
     }
     $mapping = $interface->getChildrenClassMapping();
     if (!empty($mapping)) {
         $resolveType = function ($object) use($mapping) {
             foreach ($mapping as $class => $typeName) {
                 if ($object instanceof $class) {
                     return $this->typeResolver->getType($typeName);
                 }
             }
         };
         $interface->setResolveType($resolveType);
     }
     $interface = new GQLDefinition\InterfaceType($interface->toMapping());
     return $interface;
 }