dmitri.shuralyov.com/service/change/...

githubapi: omit states argument for "all" filter

When calling List or Count with change.FilterAll, omit the "states"
argument from the GraphQL query, rather than using an empty list ([]).

This is simpler and produces more consistent results.¹

¹ https://github.community/t5/GitHub-API-Development-and/Inconsistency-of-empty-state-filter-between-Repository-issues/m-p/30659#M2888
dmitshur committed 2 weeks ago commit 011d2fcff0d76baa0352ecae474a802553b46c52
githubapi/githubapi.go
@@ -48,16 +48,16 @@ func (s service) List(ctx context.Context, rs string, opt change.ListOptions) ([
 	repo, err := ghRepoSpec(rs)
 	if err != nil {
 		// TODO: Map to 400 Bad Request HTTP error.
 		return nil, err
 	}
-	var states []githubv4.PullRequestState
+	var states *[]githubv4.PullRequestState
 	switch opt.Filter {
 	case change.FilterOpen:
-		states = []githubv4.PullRequestState{githubv4.PullRequestStateOpen}
+		states = &[]githubv4.PullRequestState{githubv4.PullRequestStateOpen}
 	case change.FilterClosedMerged:
-		states = []githubv4.PullRequestState{githubv4.PullRequestStateClosed, githubv4.PullRequestStateMerged}
+		states = &[]githubv4.PullRequestState{githubv4.PullRequestStateClosed, githubv4.PullRequestStateMerged}
 	case change.FilterAll:
 		states = nil // No states to filter the PRs by.
 	default:
 		// TODO: Map to 400 Bad Request HTTP error.
 		return nil, fmt.Errorf("invalid change.ListOptions.Filter value: %q", opt.Filter)
@@ -119,16 +119,16 @@ func (s service) Count(ctx context.Context, rs string, opt change.ListOptions) (
 	repo, err := ghRepoSpec(rs)
 	if err != nil {
 		// TODO: Map to 400 Bad Request HTTP error.
 		return 0, err
 	}
-	var states []githubv4.PullRequestState
+	var states *[]githubv4.PullRequestState
 	switch opt.Filter {
 	case change.FilterOpen:
-		states = []githubv4.PullRequestState{githubv4.PullRequestStateOpen}
+		states = &[]githubv4.PullRequestState{githubv4.PullRequestStateOpen}
 	case change.FilterClosedMerged:
-		states = []githubv4.PullRequestState{githubv4.PullRequestStateClosed, githubv4.PullRequestStateMerged}
+		states = &[]githubv4.PullRequestState{githubv4.PullRequestStateClosed, githubv4.PullRequestStateMerged}
 	case change.FilterAll:
 		states = nil // No states to filter the PRs by.
 	default:
 		// TODO: Map to 400 Bad Request HTTP error.
 		return 0, fmt.Errorf("invalid change.ListOptions.Filter value: %q", opt.Filter)