From 02c48654ad609d71861e33883cff1ac3770d501d Mon Sep 17 00:00:00 2001 From: Sam Park Date: Wed, 3 Jun 2020 11:02:20 -0700 Subject: [PATCH] Fix GraphQL URL for Github Enterprise Fixes #1009 --- server/events/vcs/github_client.go | 4 +++- server/events/vcs/github_client_internal_test.go | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server/events/vcs/github_client.go b/server/events/vcs/github_client.go index 10bd600afe..c671508dee 100644 --- a/server/events/vcs/github_client.go +++ b/server/events/vcs/github_client.go @@ -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) diff --git a/server/events/vcs/github_client_internal_test.go b/server/events/vcs/github_client_internal_test.go index 9185344a09..0109ab3854 100644 --- a/server/events/vcs/github_client_internal_test.go +++ b/server/events/vcs/github_client_internal_test.go @@ -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. }