You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "klesh (via GitHub)" <gi...@apache.org> on 2024/06/04 08:22:11 UTC

Re: [PR] fix(github): use different graphql path in enterprise version [incubator-devlake]

klesh commented on code in PR #7541:
URL: https://github.com/apache/incubator-devlake/pull/7541#discussion_r1619684908


##########
backend/plugins/github_graphql/impl/impl.go:
##########
@@ -204,11 +204,18 @@ func (p GithubGraphql) PrepareTaskData(taskCtx plugin.TaskContext, options map[s
 	}
 
 	httpClient := oauth2.NewClient(oauthContext, src)
-	endpoint, err := errors.Convert01(url.JoinPath(connection.Endpoint, `graphql`))
+	endpoint, err := errors.Convert01(url.Parse(connection.Endpoint))
 	if err != nil {
 		return nil, errors.BadInput.Wrap(err, fmt.Sprintf("malformed connection endpoint supplied: %s", connection.Endpoint))
 	}
-	client := graphql.NewClient(endpoint, httpClient)
+
+	// github.com and github enterprise have different graphql endpoints
+	endpoint.Path = "/graphql" // see https://docs.github.com/en/graphql/guides/forming-calls-with-graphql
+	if endpoint.Hostname() != "api.github.com" {
+		// see https://docs.github.com/en/enterprise-server@3.11/graphql/guides/forming-calls-with-graphql
+		endpoint.Path = "/api/graphql"

Review Comment:
   LGTM overall.
   I just want to make sure that all On-premise GitHub deployments are Enterprise Edition? Or in other words, do they all follow this URL-forming pattern?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org