public static function convert(?NodeInterface $node, TypeInterface $type, array $variables = [])
    {
        if (null === $node) {
            throw new ConversionException('Node is not defined.');
        }

        if ($type instanceof NonNullType) {
            return self::convertNonNullType($node, $type, $variables);
        }

        if ($node instanceof NullValueNode) {
            return null;
        }

        if ($node instanceof VariableNode) {
            return self::convertVariable($node, $variables);
        }

        if ($type instanceof ListType) {
            return self::convertListType($node, $type, $variables);
        }

        if ($type instanceof InputObjectType) {
            return self::convertInputObjectType($node, $type, $variables);
        }

        if ($type instanceof EnumType) {
            return self::convertEnumType($node, $type);
        }

        if ($type instanceof ScalarType) {
            return self::convertScalarType($node, $type, $variables);
        }

        throw new InvalidTypeException(\sprintf('Unknown type: %s', (string)$type));
    }