MCPcopy
hub / github.com/cli/cli / ProjectFields

Method ProjectFields

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

ProjectFields returns a project with fields. If the OwnerType is VIEWER, no login is required. If limit is 0, the default limit is used.

(o *Owner, number int32, limit int)

Source from the content-addressed store, hash-verified

1034// ProjectFields returns a project with fields. If the OwnerType is VIEWER, no login is required.
1035// If limit is 0, the default limit is used.
1036func (c *Client) ProjectFields(o *Owner, number int32, limit int) (*Project, error) {
1037 project := &Project{}
1038 if limit == 0 {
1039 limit = LimitDefault
1040 }
1041
1042 // set first to the min of limit and LimitMax
1043 first := LimitMax
1044 if limit < first {
1045 first = limit
1046 }
1047 variables := map[string]interface{}{
1048 "firstItems": githubv4.Int(LimitMax),
1049 "afterItems": (*githubv4.String)(nil),
1050 "firstFields": githubv4.Int(first),
1051 "afterFields": (*githubv4.String)(nil),
1052 "number": githubv4.Int(number),
1053 }
1054
1055 var query pager[ProjectField]
1056 var queryName string
1057 switch o.Type {
1058 case UserOwner:
1059 variables["login"] = githubv4.String(o.Login)
1060 query = &userOwnerWithFields{}
1061 queryName = "UserProjectWithFields"
1062 case OrgOwner:
1063 variables["login"] = githubv4.String(o.Login)
1064 query = &orgOwnerWithFields{}
1065 queryName = "OrgProjectWithFields"
1066 case ViewerOwner:
1067 query = &viewerOwnerWithFields{}
1068 queryName = "ViewerProjectWithFields"
1069 }
1070 err := c.doQueryWithProgressIndicator(queryName, query, variables)
1071 if err != nil {
1072 return project, err
1073 }
1074 project = query.Project()
1075
1076 fields, err := paginateAttributes(c, query, variables, queryName, "firstFields", "afterFields", limit, query.Nodes())
1077 if err != nil {
1078 return project, err
1079 }
1080
1081 project.Fields.Nodes = fields
1082 return project, nil
1083}
1084
1085// viewerLogin is used to query the Login of the viewer.
1086type viewerLogin struct {

Callers 4

runListFunction · 0.80

Calls 5

paginateAttributesFunction · 0.85
ProjectMethod · 0.65
NodesMethod · 0.65
StringMethod · 0.45

Tested by 3