public static function _type()
{
if (!isset(self::$map['__Type'])) {
self::$map['__Type'] = new ObjectType(['name' => '__Type', 'description' => 'The fundamental unit of any GraphQL Schema is the type. There are ' . 'many kinds of types in GraphQL as represented by the `__TypeKind` enum.' . "\n\n" . 'Depending on the kind of a type, certain fields describe ' . 'information about that type. Scalar types provide no information ' . 'beyond a name and description, while Enum types provide their values. ' . 'Object and Interface types provide the fields they describe. Abstract ' . 'types, Union and Interface, provide the Object types possible ' . 'at runtime. List and NonNull types compose other types.', 'fields' => function () {
return ['kind' => ['type' => Type::nonNull(self::_typeKind()), 'resolve' => function (Type $type) {
switch (true) {
case $type instanceof ListOfType:
return TypeKind::LIST_KIND;
case $type instanceof NonNull:
return TypeKind::NON_NULL;
case $type instanceof ScalarType:
return TypeKind::SCALAR;
case $type instanceof ObjectType:
return TypeKind::OBJECT;
case $type instanceof EnumType:
return TypeKind::ENUM;
case $type instanceof InputObjectType:
return TypeKind::INPUT_OBJECT;
case $type instanceof InterfaceType:
return TypeKind::INTERFACE_KIND;
case $type instanceof UnionType:
return TypeKind::UNION;
default:
throw new \Exception("Unknown kind of type: " . Utils::printSafe($type));
}
}], 'name' => ['type' => Type::string()], 'description' => ['type' => Type::string()], 'fields' => ['type' => Type::listOf(Type::nonNull(self::_field())), 'args' => ['includeDeprecated' => ['type' => Type::boolean(), 'defaultValue' => false]], 'resolve' => function (Type $type, $args) {
if ($type instanceof ObjectType || $type instanceof InterfaceType) {
$fields = $type->getFields();
if (empty($args['includeDeprecated'])) {
$fields = array_filter($fields, function (FieldDefinition $field) {
return !$field->deprecationReason;
});
}
return array_values($fields);
}
return null;
}], 'interfaces' => ['type' => Type::listOf(Type::nonNull(self::_type())), 'resolve' => function ($type) {
if ($type instanceof ObjectType) {
return $type->getInterfaces();
}
return null;
}], 'possibleTypes' => ['type' => Type::listOf(Type::nonNull(self::_type())), 'resolve' => function ($type, $args, $context, ResolveInfo $info) {
if ($type instanceof InterfaceType || $type instanceof UnionType) {
return $info->schema->getPossibleTypes($type);
}
return null;
}], 'enumValues' => ['type' => Type::listOf(Type::nonNull(self::_enumValue())), 'args' => ['includeDeprecated' => ['type' => Type::boolean(), 'defaultValue' => false]], 'resolve' => function ($type, $args) {
if ($type instanceof EnumType) {
$values = array_values($type->getValues());
if (empty($args['includeDeprecated'])) {
$values = array_filter($values, function ($value) {
return !$value->deprecationReason;
});
}
return $values;
}
return null;
}], 'inputFields' => ['type' => Type::listOf(Type::nonNull(self::_inputValue())), 'resolve' => function ($type) {
if ($type instanceof InputObjectType) {
return array_values($type->getFields());
}
return null;
}], 'ofType' => ['type' => self::_type(), 'resolve' => function ($type) {
if ($type instanceof WrappingType) {
return $type->getWrappedType();
}
return null;
}]];
}]);
}
return self::$map['__Type'];
}