GraphQL\Schema::extractTypes PHP Method

extractTypes() private method

private extractTypes ( $type ) : array
$type
return array
    private function extractTypes($type)
    {
        if (!$type) {
            return $this->typeMap;
        }
        if ($type instanceof WrappingType) {
            return $this->extractTypes($type->getWrappedType(true));
        }
        if (!empty($this->typeMap[$type->name])) {
            Utils::invariant($this->typeMap[$type->name] === $type, "Schema must contain unique named types but contains multiple types named \"{$type}\".");
            return $this->typeMap;
        }
        $this->typeMap[$type->name] = $type;
        $nestedTypes = [];
        if ($type instanceof UnionType) {
            $nestedTypes = $type->getTypes();
        }
        if ($type instanceof ObjectType) {
            $nestedTypes = array_merge($nestedTypes, $type->getInterfaces());
        }
        if ($type instanceof ObjectType || $type instanceof InterfaceType || $type instanceof InputObjectType) {
            foreach ((array) $type->getFields() as $fieldName => $field) {
                if (isset($field->args)) {
                    $fieldArgTypes = array_map(function ($arg) {
                        return $arg->getType();
                    }, $field->args);
                    $nestedTypes = array_merge($nestedTypes, $fieldArgTypes);
                }
                $nestedTypes[] = $field->getType();
            }
        }
        foreach ($nestedTypes as $type) {
            $this->extractTypes($type);
        }
        return $this->typeMap;
    }