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

Function paginateAttributes

pkg/cmd/project/shared/queries/queries.go:928–952  ·  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

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