GraphQL\Type\Definition\ObjectType::getInterfaces PHP Method

getInterfaces() public method

public getInterfaces ( ) : InterfaceType[]
return InterfaceType[]
    public function getInterfaces()
    {
        if (null === $this->interfaces) {
            $interfaces = isset($this->config['interfaces']) ? $this->config['interfaces'] : [];
            $interfaces = is_callable($interfaces) ? call_user_func($interfaces) : $interfaces;
            $this->interfaces = [];
            foreach ($interfaces as $iface) {
                $iface = Type::resolve($iface);
                if (!$iface instanceof InterfaceType) {
                    throw new InvariantViolation("Expecting interface type, got " . Utils::printSafe($iface));
                }
                $this->interfaces[] = $iface;
            }
        }
        return $this->interfaces;
    }

Usage Example

Example #1
0
 /**
  * Update the interfaces to know about this implementation.
  * This is an rare and unfortunate use of mutation in the type definition
  * implementations, but avoids an expensive "getPossibleTypes"
  * implementation for Interface types.
  *
  * @param ObjectType $impl
  * @param InterfaceType[] $interfaces
  */
 public static function addImplementationToInterfaces(ObjectType $impl)
 {
     foreach ($impl->getInterfaces() as $interface) {
         $interface->_implementations[] = $impl;
     }
 }
All Usage Examples Of GraphQL\Type\Definition\ObjectType::getInterfaces