func (ept *EquipmentPortTypeQuery) Paginate(ctx context.Context, after *Cursor, first *int, before *Cursor, last *int) (*EquipmentPortTypeConnection, error) {
	if first != nil && last != nil {
		return nil, ErrInvalidPagination
	}
	if first != nil {
		if *first == 0 {
			return &EquipmentPortTypeConnection{
				Edges: []*EquipmentPortTypeEdge{},
			}, nil
		} else if *first < 0 {
			return nil, ErrInvalidPagination
		}
	}
	if last != nil {
		if *last == 0 {
			return &EquipmentPortTypeConnection{
				Edges: []*EquipmentPortTypeEdge{},
			}, nil
		} else if *last < 0 {
			return nil, ErrInvalidPagination
		}
	}

	if after != nil {
		ept = ept.Where(equipmentporttype.IDGT(after.ID))
	}
	if before != nil {
		ept = ept.Where(equipmentporttype.IDLT(before.ID))
	}
	if first != nil {
		ept = ept.Order(Asc(equipmentporttype.FieldID)).Limit(*first + 1)
	}
	if last != nil {
		ept = ept.Order(Desc(equipmentporttype.FieldID)).Limit(*last + 1)
	}
	ept = ept.collectConnectionFields(ctx)

	nodes, err := ept.All(ctx)
	if err != nil || len(nodes) == 0 {
		return &EquipmentPortTypeConnection{
			Edges: []*EquipmentPortTypeEdge{},
		}, err
	}
	if last != nil {
		for left, right := 0, len(nodes)-1; left < right; left, right = left+1, right-1 {
			nodes[left], nodes[right] = nodes[right], nodes[left]
		}
	}

	var conn EquipmentPortTypeConnection
	if first != nil && len(nodes) > *first {
		conn.PageInfo.HasNextPage = true
		nodes = nodes[:len(nodes)-1]
	} else if last != nil && len(nodes) > *last {
		conn.PageInfo.HasPreviousPage = true
		nodes = nodes[1:]
	}
	conn.Edges = make([]*EquipmentPortTypeEdge, len(nodes))
	for i, node := range nodes {
		conn.Edges[i] = &EquipmentPortTypeEdge{
			Node: node,
			Cursor: Cursor{
				ID: node.ID,
			},
		}
	}
	conn.PageInfo.StartCursor = &conn.Edges[0].Cursor
	conn.PageInfo.EndCursor = &conn.Edges[len(conn.Edges)-1].Cursor

	return &conn, nil
}
// Paginate executes the query and returns a relay based cursor connection to EquipmentPortType.
Paginate executes the query and returns a relay based cursor connection to EquipmentPortType.
// Paginate executes the query and returns a relay based cursor connection to EquipmentPortType .
func (ept *EquipmentPortTypeQuery) Paginate(ctx context.Context, after *Cursor, first *int, before *Cursor, last *int) (*EquipmentPortTypeConnection, error) {
	if first != nil && last != nil {
		return nil, ErrInvalidPagination
	}
	if first != nil {
		if *first == 0 {
			return &EquipmentPortTypeConnection{
				Edges: []*EquipmentPortTypeEdge{},
			}, nil
		} else if *first < 0 {
			return nil, ErrInvalidPagination
		}
	}
	if last != nil {
		if *last == 0 {
			return &EquipmentPortTypeConnection{
				Edges: []*EquipmentPortTypeEdge{},
			}, nil
		} else if *last < 0 {
			return nil, ErrInvalidPagination
		}
	}
	if after != nil {
		ept = ept.Where(equipmentporttype.IDGT(after.ID))
	}
	if before != nil {
		ept = ept.Where(equipmentporttype.IDLT(before.ID))
	}
	if first != nil {
		ept = ept.Order(Asc(equipmentporttype.FieldID)).Limit(*first + 1)
	}
	if last != nil {
		ept = ept.Order(Desc(equipmentporttype.FieldID)).Limit(*last + 1)
	}
	ept = ept.collectConnectionFields(ctx)
	nodes, err := ept.All(ctx)
	if err != nil || len(nodes) == 0 {
		return &EquipmentPortTypeConnection{
			Edges: []*EquipmentPortTypeEdge{},
		}, err
	}
	if last != nil {
		for left, right := 0, len(nodes)-1; left < right; left, right = left+1, right-1 {
			nodes[left], nodes[right] = nodes[right], nodes[left]
		}
	}
	var conn EquipmentPortTypeConnection
	if first != nil && len(nodes) > *first {
		conn.PageInfo.HasNextPage = true
		nodes = nodes[:len(nodes)-1]
	} else if last != nil && len(nodes) > *last {
		conn.PageInfo.HasPreviousPage = true
		nodes = nodes[1:]
	}
	conn.Edges = make([]*EquipmentPortTypeEdge, len(nodes))
	for i, node := range nodes {
		conn.Edges[i] = &EquipmentPortTypeEdge{
			Node: node,
			Cursor: Cursor{
				ID: node.ID,
			},
		}
	}
	conn.PageInfo.StartCursor = &conn.Edges[0].Cursor
	conn.PageInfo.EndCursor = &conn.Edges[len(conn.Edges)-1].Cursor
	return &conn, nil
}
func ( ept * EquipmentPortTypeQuery ) Paginate ( ctx context . Context , after * Cursor , first * int , before * Cursor , last * int ) ( * EquipmentPortTypeConnection , error ) { if first != nil && last != nil { return nil , ErrInvalidPagination } if first != nil { if * first == 0 { return & EquipmentPortTypeConnection { Edges : [ ] * EquipmentPortTypeEdge { } , } , nil } else if * first < 0 { return nil , ErrInvalidPagination } } if last != nil { if * last == 0 { return & EquipmentPortTypeConnection { Edges : [ ] * EquipmentPortTypeEdge { } , } , nil } else if * last < 0 { return nil , ErrInvalidPagination } } if after != nil { ept = ept . Where ( equipmentporttype . IDGT ( after . ID ) ) } if before != nil { ept = ept . Where ( equipmentporttype . IDLT ( before . ID ) ) } if first != nil { ept = ept . Order ( Asc ( equipmentporttype . FieldID ) ) . Limit ( * first + 1 ) } if last != nil { ept = ept . Order ( Desc ( equipmentporttype . FieldID ) ) . Limit ( * last + 1 ) } ept = ept . collectConnectionFields ( ctx ) nodes , err := ept . All ( ctx ) if err != nil || len ( nodes ) == 0 { return & EquipmentPortTypeConnection { Edges : [ ] * EquipmentPortTypeEdge { } , } , err } if last != nil { for left , right := 0 , len ( nodes ) - 1 ; left < right ; left , right = left + 1 , right - 1 { nodes [ left ] , nodes [ right ] = nodes [ right ] , nodes [ left ] } } var conn EquipmentPortTypeConnection if first != nil && len ( nodes ) > * first { conn . PageInfo . HasNextPage = true nodes = nodes [ : len ( nodes ) - 1 ] } else if last != nil && len ( nodes ) > * last { conn . PageInfo . HasPreviousPage = true nodes = nodes [ 1 : ] } conn . Edges = make ( [ ] * EquipmentPortTypeEdge , len ( nodes ) ) for i , node := range nodes { conn . Edges [ i ] = & EquipmentPortTypeEdge { Node : node , Cursor : Cursor { ID : node . ID , } , } } conn . PageInfo . StartCursor = & conn . Edges [ 0 ] . Cursor conn . PageInfo . EndCursor = & conn . Edges [ len ( conn . Edges ) - 1 ] . Cursor return & conn , nil }
Paginate executes the query and returns a relay based cursor connection to EquipmentPortType.
Paginate executes the query and returns a relay based cursor connection to EquipmentPortType .