상속: extends Youshido\GraphQL\Type\AbstractType, use trait Youshido\GraphQL\Type\Traits\FieldsAwareObjectTrait, use trait Youshido\GraphQL\Type\Traits\AutoNameTrait
예제 #1
0
 public function assertTypeImplementsInterface(AbstractType $type, AbstractInterfaceType $interface)
 {
     if ($type instanceof AbstractObjectType) {
         foreach ($type->getInterfaces() as $typeInterface) {
             if ($typeInterface->getName() == $interface->getName()) {
                 return;
             }
         }
     }
     throw new ResolveException(sprintf('Type "%s" does not implement "%s"', $type->getName(), $interface->getName()));
 }
예제 #2
0
 /**
  * @param Field                 $intField
  * @param Field                 $objField
  * @param AbstractInterfaceType $interface
  *
  * @return bool
  *
  * @throws ConfigurationException
  */
 protected function assertFieldsIdentical($intField, $objField, AbstractInterfaceType $interface)
 {
     $isValid = true;
     if ($intField->getType()->isCompositeType() !== $objField->getType()->isCompositeType()) {
         $isValid = false;
     }
     if ($intField->getType()->getNamedType()->getName() != $objField->getType()->getNamedType()->getName()) {
         $isValid = false;
     }
     if (!$isValid) {
         throw new ConfigurationException(sprintf('Implementation of %s is invalid for the field %s', $interface->getName(), $objField->getName()));
     }
 }
예제 #3
0
 /**
  * Add fields from passed interface
  * @param AbstractInterfaceType $interfaceType
  * @return $this
  */
 public function applyInterface(AbstractInterfaceType $interfaceType)
 {
     $this->addFields($interfaceType->getFields());
     return $this;
 }