Skip to content

Commit 9e47910

Browse files
carocadabeizn
authored andcommitted
fix(github): use different graphql path in enterprise version (#7541)
1 parent 21cfa05 commit 9e47910

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

  • backend/plugins/github_graphql/impl

backend/plugins/github_graphql/impl/impl.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,18 @@ func (p GithubGraphql) PrepareTaskData(taskCtx plugin.TaskContext, options map[s
204204
}
205205

206206
httpClient := oauth2.NewClient(oauthContext, src)
207-
endpoint, err := errors.Convert01(url.JoinPath(connection.Endpoint, `graphql`))
207+
endpoint, err := errors.Convert01(url.Parse(connection.Endpoint))
208208
if err != nil {
209209
return nil, errors.BadInput.Wrap(err, fmt.Sprintf("malformed connection endpoint supplied: %s", connection.Endpoint))
210210
}
211-
client := graphql.NewClient(endpoint, httpClient)
211+
212+
// github.com and github enterprise have different graphql endpoints
213+
endpoint.Path = "/graphql" // see https://docs.github.com/en/graphql/guides/forming-calls-with-graphql
214+
if endpoint.Hostname() != "api.github.com" {
215+
// see https://docs.github.com/en/enterprise-server@3.11/graphql/guides/forming-calls-with-graphql
216+
endpoint.Path = "/api/graphql"
217+
}
218+
client := graphql.NewClient(endpoint.String(), httpClient)
212219
graphqlClient, err := helper.CreateAsyncGraphqlClient(taskCtx, client, taskCtx.GetLogger(),
213220
func(ctx context.Context, client *graphql.Client, logger log.Logger) (rateRemaining int, resetAt *time.Time, err errors.Error) {
214221
var query GraphQueryRateLimit

0 commit comments

Comments
 (0)