src/Connection/Connection.php
public static function createEdgeType(array $config)
    {
        if (!array_key_exists('nodeType', $config)){
            throw new \InvalidArgumentException('Edge config needs to have at least a node definition');
        }
        $nodeType = $config['nodeType'];
        $name = array_key_exists('name', $config) ? $config['name'] : $nodeType->name;
        $edgeFields = array_key_exists('edgeFields', $config) ? $config['edgeFields'] : [];
        $resolveNode = array_key_exists('resolveNode', $config) ? $config['resolveNode'] : null;
        $resolveCursor = array_key_exists('resolveCursor', $config) ? $config['resolveCursor'] : null;

        $edgeType = new ObjectType(array_merge([
            'name' => $name . 'Edge',
            'description' => 'An edge in a connection',
            'fields' => function() use ($nodeType, $resolveNode, $resolveCursor, $edgeFields) {
                return array_merge([
                    'node' => [
                        'type' => $nodeType,
                        'resolve' => $resolveNode,
                        'description' => 'The item at the end of the edge'
                    ],
                    'cursor' => [
                        'type' => Type::nonNull(Type::string()),
                        'resolve' => $resolveCursor,
                        'description' => 'A cursor for use in pagination'
                    ]
                ], self::resolveMaybeThunk($edgeFields));
            }
        ]));

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

        $edgeType = new ObjectType(array_merge([
            'name' => $name . 'Edge',
            'description' => 'An edge in a connection',
            'fields' => function() use ($nodeType, $resolveNode, $resolveCursor, $edgeFields) {
                return array_merge([
                    'node' => [
                        'type' => $nodeType,
                        'resolve' => $resolveNode,
                        'description' => 'The item at the end of the edge'
                    ],
                    'cursor' => [
                        'type' => Type::nonNull(Type::string()),
                        'resolve' => $resolveCursor,
                        'description' => 'A cursor for use in pagination'
                    ]
                ], self::resolveMaybeThunk($edgeFields));
            }
        ]));

        return $edgeType;
    }
public static function createEdgeType ( array $ config ) { if ( ! array_key_exists ( 'nodeType' , $ config ) ) { throw new \ InvalidArgumentException ( 'Edge config needs to have at least a node definition' ) ; } $ nodeType = $ config [ 'nodeType' ] ; $ name = array_key_exists ( 'name' , $ config ) ? $ config [ 'name' ] : $ nodeType -> name ; $ edgeFields = array_key_exists ( 'edgeFields' , $ config ) ? $ config [ 'edgeFields' ] : [ ] ; $ resolveNode = array_key_exists ( 'resolveNode' , $ config ) ? $ config [ 'resolveNode' ] : null ; $ resolveCursor = array_key_exists ( 'resolveCursor' , $ config ) ? $ config [ 'resolveCursor' ] : null ; $ edgeType = new ObjectType ( array_merge ( [ 'name' => $ name . 'Edge' , 'description' => 'An edge in a connection' , 'fields' => function ( ) use ( $ nodeType , $ resolveNode , $ resolveCursor , $ edgeFields ) { return array_merge ( [ 'node' => [ 'type' => $ nodeType , 'resolve' => $ resolveNode , 'description' => 'The item at the end of the edge' ] , 'cursor' => [ 'type' => Type :: nonNull ( Type :: string ( ) ) , 'resolve' => $ resolveCursor , 'description' => 'A cursor for use in pagination' ] ] , self :: resolveMaybeThunk ( $ edgeFields ) ) ; } ] ) ) ; return $ edgeType ; }
Returns a GraphQLObjectType for an edge with the given name,
and whose nodes are of the specified type.

@param array $config
@return ObjectType
Returns a GraphQLObjectType for an edge with the given name and whose nodes are of the specified type .