Skip to content

Commit

Permalink
Fix GraphQL URL for Github Enterprise
Browse files Browse the repository at this point in the history
Fixes #1009
  • Loading branch information
Sam Park committed Jun 3, 2020
1 parent 6e0f265 commit 02c4865
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/events/vcs/github_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ func NewGithubClient(hostname string, user string, pass string, logger *logging.
return nil, errors.Wrapf(err, "Invalid github hostname trying to parse %s", baseURL)
}
client.BaseURL = base
graphqlURL = fmt.Sprintf("https://%s/graphql", hostname)
// Github Enterprise uses a slightly different endpoint format for GraphQL.
// https://developer.github.com/enterprise/2.20/v4/guides/forming-calls/#the-graphql-endpoint
graphqlURL = fmt.Sprintf("https://%s/api/graphql", hostname)
_, err = url.Parse(graphqlURL)
if err != nil {
return nil, errors.Wrapf(err, "Invalid GraphQL github hostname trying to parse %s", graphqlURL)
Expand Down
2 changes: 2 additions & 0 deletions server/events/vcs/github_client_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ func TestNewGithubClient_NonGithub(t *testing.T) {
client, err := NewGithubClient("example.com", "user", "pass", nil)
Ok(t, err)
Equals(t, "https://example.com/api/v3/", client.client.BaseURL.String())
// If possible in the future, test the GraphQL client's URL as well. But at the
// moment the shurcooL library doesn't expose it.
}

0 comments on commit 02c4865

Please sign in to comment.