Skip to content

Commit 0ab911e

Browse files
authored
If the instance URL isn't github.com, create an enterprise graphql client (#17)
1 parent 4865375 commit 0ab911e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/connector/connector.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func New(ctx context.Context, githubOrgs []string, instanceURL, accessToken stri
158158
if err != nil {
159159
return nil, err
160160
}
161-
graphqlClient, err := newGithubGraphqlClient(ctx, accessToken)
161+
graphqlClient, err := newGithubGraphqlClient(ctx, instanceURL, accessToken)
162162
if err != nil {
163163
return nil, err
164164
}
@@ -172,7 +172,7 @@ func New(ctx context.Context, githubOrgs []string, instanceURL, accessToken stri
172172
return gh, nil
173173
}
174174

175-
func newGithubGraphqlClient(ctx context.Context, accessToken string) (*githubv4.Client, error) {
175+
func newGithubGraphqlClient(ctx context.Context, instanceURL string, accessToken string) (*githubv4.Client, error) {
176176
httpClient, err := uhttp.NewClient(ctx, uhttp.WithLogger(true, ctxzap.Extract(ctx)))
177177
if err != nil {
178178
return nil, err
@@ -184,5 +184,11 @@ func newGithubGraphqlClient(ctx context.Context, accessToken string) (*githubv4.
184184
&oauth2.Token{AccessToken: accessToken},
185185
)
186186
tc := oauth2.NewClient(ctx, ts)
187+
188+
instanceURL = strings.TrimSuffix(instanceURL, "/")
189+
if instanceURL != "" && instanceURL != githubDotCom {
190+
return githubv4.NewEnterpriseClient(instanceURL, httpClient), nil
191+
}
192+
187193
return githubv4.NewClient(tc), nil
188194
}

0 commit comments

Comments
 (0)