Inheritance: extends Youshido\GraphQL\Type\AbstractType, use trait Youshido\GraphQL\Type\Traits\AutoNameTrait, use trait Youshido\GraphQL\Type\Traits\FieldsArgumentsAwareObjectTrait
Exemple #1
0
 /**
  * @param AbstractObjectType $type
  *
  * @throws ConfigurationException
  */
 protected function assertInterfaceImplementationCorrect(AbstractObjectType $type)
 {
     if (!$type->getInterfaces()) {
         return;
     }
     foreach ($type->getInterfaces() as $interface) {
         foreach ($interface->getConfig()->getFields() as $intField) {
             $this->assertFieldsIdentical($intField, $type->getConfig()->getField($intField->getName()), $interface);
         }
     }
 }
Exemple #2
0
 private function collectResult(FieldInterface $field, AbstractObjectType $type, $ast, $resolvedValue)
 {
     /** @var AstQuery $ast */
     $result = [];
     foreach ($ast->getFields() as $astField) {
         switch (true) {
             case $astField instanceof TypedFragmentReference:
                 $astName = $astField->getTypeName();
                 $typeName = $type->getName();
                 if ($typeName !== $astName) {
                     foreach ($type->getInterfaces() as $interface) {
                         if ($interface->getName() === $astName) {
                             $result = array_merge($result, $this->collectResult($field, $type, $astField, $resolvedValue));
                             break;
                         }
                     }
                     continue;
                 }
                 $result = array_merge($result, $this->collectResult($field, $type, $astField, $resolvedValue));
                 break;
             case $astField instanceof FragmentReference:
                 $astFragment = $this->executionContext->getRequest()->getFragment($astField->getName());
                 $astFragmentModel = $astFragment->getModel();
                 $typeName = $type->getName();
                 if ($typeName !== $astFragmentModel) {
                     foreach ($type->getInterfaces() as $interface) {
                         if ($interface->getName() === $astFragmentModel) {
                             $result = array_merge($result, $this->collectResult($field, $type, $astFragment, $resolvedValue));
                             break;
                         }
                     }
                     continue;
                 }
                 $result = array_merge($result, $this->collectResult($field, $type, $astFragment, $resolvedValue));
                 break;
             default:
                 $result[$this->getAlias($astField)] = $this->resolveField($field, $astField, $resolvedValue, true);
         }
     }
     return $result;
 }