diff --git a/api/queries.go b/api/queries.go index aa26c0be0..ece7e7a77 100644 --- a/api/queries.go +++ b/api/queries.go @@ -21,6 +21,8 @@ type PullRequest struct { HeadRefName string } +var OverriddenQueryFunction func(query string, variables map[string]string, v interface{}) error + func PullRequests() (PullRequestsPayload, error) { type edges struct { Edges []struct { @@ -98,7 +100,12 @@ func PullRequests() (PullRequestsPayload, error) { } var resp response - err := graphQL(query, variables, &resp) + var err error + if OverriddenQueryFunction != nil { + err = OverriddenQueryFunction(query, variables, &resp) + } else { + err = graphQL(query, variables, &resp) + } if err != nil { return PullRequestsPayload{}, err } diff --git a/command/fixtures/pr.json b/command/fixtures/pr.json new file mode 100644 index 000000000..3d2507c0e --- /dev/null +++ b/command/fixtures/pr.json @@ -0,0 +1,30 @@ +{ + "repository": { + "pullRequests": { + "edges": [ + { + "node": { + "number": 10, + "title": "test", + "url": "https://github.com/github/gh-cli/pull/10", + "headRefName": "test" + } + } + ] + } + }, + "viewerCreated": { + "edges": [ + { + "node": { + "number": 8, + "title": "Pull in the GraphQL API functionality", + "url": "https://github.com/github/gh-cli/pull/8", + "headRefName": "graphql" + } + } + ], + "pageInfo": { "hasNextPage": false } + }, + "reviewRequested": { "edges": [], "pageInfo": { "hasNextPage": false } } +}