MCPcopy Create free account
hub / github.com/cli/cli / paginateAttributes

Function paginateAttributes

pkg/cmd/project/shared/queries/queries.go:931–955  ·  view source on GitHub ↗

paginateAttributes is for paginating over the attributes of a project, such as items or fields firstKey and afterKey are the keys in the variables map that are used to set the first and after as these are set independently based on the attribute type, such as item or field. limit is the maximum nu

(c *Client, p pager[N], variables map[string]any, queryName string, firstKey string, afterKey string, limit int, nodes []N)

Source from the content-addressed store, hash-verified

929//
930// the return value is a slice of the newly fetched attributes appended to nodes.
931func paginateAttributes[N projectAttribute](c *Client, p pager[N], variables map[string]any, queryName string, firstKey string, afterKey string, limit int, nodes []N) ([]N, error) {
932 hasNextPage := p.HasNextPage()
933 cursor := p.EndCursor()
934 for {
935 if !hasNextPage || len(nodes) >= limit {
936 return nodes, nil
937 }
938
939 if len(nodes)+LimitMax > limit {
940 first := limit - len(nodes)
941 variables[firstKey] = githubv4.Int(first)
942 }
943
944 // set the cursor to the end of the last page
945 variables[afterKey] = (*githubv4.String)(&cursor)
946 err := c.doQueryWithProgressIndicator(queryName, p, variables)
947 if err != nil {
948 return nodes, err
949 }
950
951 nodes = append(nodes, p.Nodes()...)
952 hasNextPage = p.HasNextPage()
953 cursor = p.EndCursor()
954 }
955}
956
957// ProjectField is a ProjectV2FieldConfiguration GraphQL object https://docs.github.com/en/graphql/reference/unions#projectv2fieldconfiguration.
958type ProjectField struct {

Callers 2

ProjectItemsMethod · 0.85
ProjectFieldsMethod · 0.85

Calls 4

HasNextPageMethod · 0.65
EndCursorMethod · 0.65
NodesMethod · 0.65

Tested by

no test coverage detected