queries

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IssueOrPullRequestID

func IssueOrPullRequestID(client api.GQLClient, rawURL string) (string, error)

IssueOrPullRequestID returns the ID of the issue or pull request from a URL.

func NewClient

func NewClient() (api.GQLClient, error)

func OwnerID

func OwnerID(client api.GQLClient, login string, t OwnerType) (string, error)

OwnerID returns the ID of an OwnerType. If the OwnerType is VIEWER, no login is required.

func ViewerLoginName

func ViewerLoginName(client api.GQLClient) (string, error)

ViewerLoginName returns the login name of the viewer.

Types

type ClientOptions

type ClientOptions struct {
	Timeout time.Duration
}

type DraftIssue

type DraftIssue struct {
	ID    string
	Body  string
	Title string
}

type FieldValueNodes added in v1.2.0

type FieldValueNodes struct {
	Type                        string `graphql:"__typename"`
	ProjectV2ItemFieldDateValue struct {
		Date  string
		Field ProjectField
	} `graphql:"... on ProjectV2ItemFieldDateValue"`
	ProjectV2ItemFieldIterationValue struct {
		StartDate string
		Duration  int
		Field     ProjectField
	} `graphql:"... on ProjectV2ItemFieldIterationValue"`
	ProjectV2ItemFieldLabelValue struct {
		Labels struct {
			Nodes []struct {
				Name string
			}
		} `graphql:"labels(first: 10)"` // experienced issues with larger limits, 10 seems like enough for now
		Field ProjectField
	} `graphql:"... on ProjectV2ItemFieldLabelValue"`
	ProjectV2ItemFieldNumberValue struct {
		Number float32
		Field  ProjectField
	} `graphql:"... on ProjectV2ItemFieldNumberValue"`
	ProjectV2ItemFieldSingleSelectValue struct {
		Name  string
		Field ProjectField
	} `graphql:"... on ProjectV2ItemFieldSingleSelectValue"`
	ProjectV2ItemFieldTextValue struct {
		Text  string
		Field ProjectField
	} `graphql:"... on ProjectV2ItemFieldTextValue"`
	ProjectV2ItemFieldMilestoneValue struct {
		Milestone struct {
			Description string
			DueOn       string
		}
		Field ProjectField
	} `graphql:"... on ProjectV2ItemFieldMilestoneValue"`
	ProjectV2ItemFieldPullRequestValue struct {
		PullRequests struct {
			Nodes []struct {
				Url string
			}
		} `graphql:"pullRequests(first:10)"` // experienced issues with larger limits, 10 seems like enough for now
		Field ProjectField
	} `graphql:"... on ProjectV2ItemFieldPullRequestValue"`
	ProjectV2ItemFieldRepositoryValue struct {
		Repository struct {
			Url string
		}
		Field ProjectField
	} `graphql:"... on ProjectV2ItemFieldRepositoryValue"`
	ProjectV2ItemFieldUserValue struct {
		Users struct {
			Nodes []struct {
				Login string
			}
		} `graphql:"users(first: 10)"` // experienced issues with larger limits, 10 seems like enough for now
		Field ProjectField
	} `graphql:"... on ProjectV2ItemFieldUserValue"`
	ProjectV2ItemFieldReviewerValue struct {
		Reviewers struct {
			Nodes []struct {
				Type string `graphql:"__typename"`
				Team struct {
					Name string
				} `graphql:"... on Team"`
				User struct {
					Login string
				} `graphql:"... on User"`
			}
		} `graphql:"reviewers(first: 10)"` // experienced issues with larger limits, 10 seems like enough for now
		Field ProjectField
	} `graphql:"... on ProjectV2ItemFieldReviewerValue"`
}

func (FieldValueNodes) ID added in v1.2.0

func (v FieldValueNodes) ID() string

type Issue

type Issue struct {
	Body       string
	Title      string
	Number     int
	Repository struct {
		NameWithOwner string
	}
}

type Owner

type Owner struct {
	Login string
	Type  OwnerType
	ID    string
}

func NewOwner

func NewOwner(client api.GQLClient, userLogin, orgLogin string) (*Owner, error)

NewOwner creates a project Owner When userLogin == "@me", userLogin becomes the current viewer If userLogin is not empty, it is used to lookup the user owner If orgLogin is not empty, it is used to lookup the org owner If both userLogin and orgLogin are empty, interative mode is used to select an owner from the current viewer and their organizations

type OwnerType

type OwnerType string

OwnerType is the type of the owner of a project, which can be either a user or an organization. Viewer is the current user.

const OrgOwner OwnerType = "ORGANIZATION"
const UserOwner OwnerType = "USER"
const ViewerOwner OwnerType = "VIEWER"

type PageInfo

type PageInfo struct {
	EndCursor   githubv4.String
	HasNextPage bool
}

PageInfo is a PageInfo GraphQL object https://docs.github.com/en/graphql/reference/objects#pageinfo.

type Project

type Project struct {
	Number           int
	URL              string
	ShortDescription string
	Public           bool
	Closed           bool
	Title            string
	ID               string
	Readme           string
	Items            struct {
		TotalCount int
	} `graphql:"items(first: 100)"`
	Fields struct {
		TotalCount int
		Nodes      []ProjectField
		PageInfo   PageInfo
	} `graphql:"fields(first:100)"`
	Owner struct {
		TypeName string `graphql:"__typename"`
		User     struct {
			Login string
		} `graphql:"... on User"`
		Organization struct {
			Login string
		} `graphql:"... on Organization"`
	}
}

Project is a ProjectV2 GraphQL object https://docs.github.com/en/graphql/reference/objects#projectv2.

func NewProject

func NewProject(client api.GQLClient, o *Owner, number int) (*Project, error)

NewProject creates a project based on the owner and project number if number is 0 it will prompt the user to select a project interactively otherwise it will make a request to get the project by number

func Projects

func Projects(client api.GQLClient, login string, t OwnerType) ([]Project, error)

Projects returns all the projects for an Owner. If the OwnerType is VIEWER, no login is required.

func ProjectsLimit

func ProjectsLimit(client api.GQLClient, login string, t OwnerType, limit int) ([]Project, error)

ProjectsLimit returns up to limit projects for an Owner. If the OwnerType is VIEWER, no login is required.

func (Project) OwnerLogin added in v1.6.0

func (p Project) OwnerLogin() string

func (Project) OwnerType added in v1.6.0

func (p Project) OwnerType() string

type ProjectField

type ProjectField struct {
	TypeName string `graphql:"__typename"`
	Field    struct {
		ID       string
		Name     string
		DataType string
	} `graphql:"... on ProjectV2Field"`
	IterationField struct {
		ID       string
		Name     string
		DataType string
	} `graphql:"... on ProjectV2IterationField"`
	SingleSelectField struct {
		ID       string
		Name     string
		DataType string
	} `graphql:"... on ProjectV2SingleSelectField"`
}

ProjectField is a ProjectV2FieldConfiguration GraphQL object https://docs.github.com/en/graphql/reference/unions#projectv2fieldconfiguration.

func (ProjectField) ID

func (p ProjectField) ID() string

ID is the ID of the project field.

func (ProjectField) Name

func (p ProjectField) Name() string

Name is the name of the project field.

func (ProjectField) Type

func (p ProjectField) Type() string

Type is the typename of the project field.

type ProjectItem

type ProjectItem struct {
	Content struct {
		TypeName    string      `graphql:"__typename"`
		DraftIssue  DraftIssue  `graphql:"... on DraftIssue"`
		PullRequest PullRequest `graphql:"... on PullRequest"`
		Issue       Issue       `graphql:"... on Issue"`
	}
	Id          string
	FieldValues struct {
		Nodes []FieldValueNodes
	} `graphql:"fieldValues(first: 100)"` // hardcoded to 100 for now on the assumption that this is a reasonable limit
}

ProjectItem is a ProjectV2Item GraphQL object https://docs.github.com/en/graphql/reference/objects#projectv2item.

func (ProjectItem) Body

func (p ProjectItem) Body() string

Body is the body of the project item.

func (ProjectItem) ID

func (p ProjectItem) ID() string

func (ProjectItem) Number

func (p ProjectItem) Number() int

Number is the number of the project item. It is only valid for issues and pull requests.

func (ProjectItem) Repo

func (p ProjectItem) Repo() string

Repo is the repository of the project item. It is only valid for issues and pull requests.

func (ProjectItem) Title

func (p ProjectItem) Title() string

Title is the title of the project item.

func (ProjectItem) Type

func (p ProjectItem) Type() string

Type is the underlying type of the project item.

type ProjectWithFields added in v1.5.0

type ProjectWithFields struct {
	Fields struct {
		PageInfo PageInfo
		Nodes    []ProjectField
	} `graphql:"fields(first: $first, after: $after)"`
}

func ProjectFields

func ProjectFields(client api.GQLClient, o *Owner, number int, first int) (ProjectWithFields, error)

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

type ProjectWithItems added in v1.2.0

type ProjectWithItems struct {
	Number           int
	URL              string
	ShortDescription string
	Public           bool
	Closed           bool
	Title            string
	ID               string
	Readme           string
	Items            struct {
		PageInfo   PageInfo
		TotalCount int
		Nodes      []ProjectItem
	} `graphql:"items(first: $first, after: $after)"`
	Fields struct {
		Nodes []ProjectField
	} `graphql:"fields(first:100)"`
	Owner struct {
		User struct {
			Login string
		} `graphql:"... on User"`
		Organization struct {
			Login string
		} `graphql:"... on Organization"`
	}
}

ProjectWithItems is for fetching all of the items in a single project with pagination it fetches a lot of data, be careful with it!

func ProjectItems

func ProjectItems(client api.GQLClient, o *Owner, number int, first int) (ProjectWithItems, error)

ProjectItems returns the items of a project. If the OwnerType is VIEWER, no login is required.

type PullRequest

type PullRequest struct {
	Body       string
	Title      string
	Number     int
	Repository struct {
		NameWithOwner string
	}
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL