MCPcopy
hub / github.com/cli/cli / paginateAttributes

Function paginateAttributes

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

896//
897// the return value is a slice of the newly fetched attributes appended to nodes.
898func paginateAttributes[N projectAttribute](c *Client, p pager[N], variables map[string]any, queryName string, firstKey string, afterKey string, limit int, nodes []N) ([]N, error) {
899 hasNextPage := p.HasNextPage()
900 cursor := p.EndCursor()
901 for {
902 if !hasNextPage || len(nodes) >= limit {
903 return nodes, nil
904 }
905
906 if len(nodes)+LimitMax > limit {
907 first := limit - len(nodes)
908 variables[firstKey] = githubv4.Int(first)
909 }
910
911 // set the cursor to the end of the last page
912 variables[afterKey] = (*githubv4.String)(&cursor)
913 err := c.doQueryWithProgressIndicator(queryName, p, variables)
914 if err != nil {
915 return nodes, err
916 }
917
918 nodes = append(nodes, p.Nodes()...)
919 hasNextPage = p.HasNextPage()
920 cursor = p.EndCursor()
921 }
922}
923
924// ProjectField is a ProjectV2FieldConfiguration GraphQL object https://docs.github.com/en/graphql/reference/unions#projectv2fieldconfiguration.
925type 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