Skip to content
Permalink
Browse files

githubapi: omit states argument for "all" filter

When calling List or Count with issues.AllStates, 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
  • Loading branch information...
dmitshur committed Nov 2, 2019
1 parent 6a96395 commit 669a77a17f95b37fcf483cbcb33ba077602274b1
Showing with 6 additions and 6 deletions.
  1. +6 −6 githubapi/githubapi.go
@@ -55,12 +55,12 @@ func (s service) List(ctx context.Context, rs issues.RepoSpec, opt issues.IssueL
// TODO: Map to 400 Bad Request HTTP error.
return nil, err
}
var states []githubv4.IssueState
var states *[]githubv4.IssueState
switch opt.State {
case issues.StateFilter(issues.OpenState):
states = []githubv4.IssueState{githubv4.IssueStateOpen}
states = &[]githubv4.IssueState{githubv4.IssueStateOpen}
case issues.StateFilter(issues.ClosedState):
states = []githubv4.IssueState{githubv4.IssueStateClosed}
states = &[]githubv4.IssueState{githubv4.IssueStateClosed}
case issues.AllStates:
states = nil // No states to filter the issues by.
default:
@@ -128,12 +128,12 @@ func (s service) Count(ctx context.Context, rs issues.RepoSpec, opt issues.Issue
// TODO: Map to 400 Bad Request HTTP error.
return 0, err
}
var states []githubv4.IssueState
var states *[]githubv4.IssueState
switch opt.State {
case issues.StateFilter(issues.OpenState):
states = []githubv4.IssueState{githubv4.IssueStateOpen}
states = &[]githubv4.IssueState{githubv4.IssueStateOpen}
case issues.StateFilter(issues.ClosedState):
states = []githubv4.IssueState{githubv4.IssueStateClosed}
states = &[]githubv4.IssueState{githubv4.IssueStateClosed}
case issues.AllStates:
states = nil // No states to filter the issues by.
default:

0 comments on commit 669a77a

Please sign in to comment.
You can’t perform that action at this time.