public static function createConnectionType(array $config)
    {
        if (!array_key_exists('nodeType', $config)){
            throw new \InvalidArgumentException('Connection config needs to have at least a node definition');
        }
        $nodeType = $config['nodeType'];
        $name = array_key_exists('name', $config) ? $config['name'] : $nodeType->name;
        $connectionFields = array_key_exists('connectionFields', $config) ? $config['connectionFields'] : [];
        $edgeType = array_key_exists('edgeType', $config) ? $config['edgeType'] : null;

        $connectionType = new ObjectType([
            'name' => $name . 'Connection',
            'description' => 'A connection to a list of items.',
            'fields' => function() use ($edgeType, $connectionFields, $config) {
                return array_merge([
                    'pageInfo' => [
                        'type' => Type::nonNull(self::pageInfoType()),
                        'description' => 'Information to aid in pagination.'
                    ],
                    'edges' => [
                        'type' => Type::listOf($edgeType ?: self::createEdgeType($config)),
                        'description' => 'Information to aid in pagination'
                    ]
                ], self::resolveMaybeThunk($connectionFields));
            }
        ]);

        return $connectionType;
    }