Youshido\GraphQL\Type\TypeService::isInputType PHP Method

isInputType() public static method

public static isInputType ( mixed | AbstractType $type ) : boolean
$type mixed | AbstractType
return boolean
    public static function isInputType($type)
    {
        if (is_object($type)) {
            $namedType = $type->getNullableType()->getNamedType();
            return $namedType instanceof AbstractScalarType || $type instanceof AbstractListType || $namedType instanceof AbstractInputObjectType || $namedType instanceof AbstractEnumType;
        } else {
            return TypeService::isScalarType($type);
        }
    }

Usage Example

Ejemplo n.º 1
0
 public function testIsInputType()
 {
     $testType = new ObjectType(['name' => 'test', 'fields' => ['name' => new StringType()]]);
     $this->assertTrue(TypeService::isInputType(new StringType()));
     $this->assertTrue(TypeService::isInputType(TypeMap::TYPE_STRING));
     $this->assertFalse(TypeService::isInputType('invalid type'));
     $this->assertFalse(TypeService::isInputType($testType));
 }
All Usage Examples Of Youshido\GraphQL\Type\TypeService::isInputType