MCPcopy Index your code
hub / github.com/github/github-mcp-server / GetGQLClient

Method GetGQLClient

pkg/github/dependencies.go:335–363  ·  view source on GitHub ↗

GetGQLClient implements ToolDependencies.

(ctx context.Context)

Source from the content-addressed store, hash-verified

333
334// GetGQLClient implements ToolDependencies.
335func (d *RequestDeps) GetGQLClient(ctx context.Context) (*githubv4.Client, error) {
336 // extract the token from the context
337 tokenInfo, ok := ghcontext.GetTokenInfo(ctx)
338 if !ok {
339 return nil, fmt.Errorf("no token info in context")
340 }
341 token := tokenInfo.Token
342
343 // Construct GraphQL client
344 // We use NewEnterpriseClient unconditionally since we already parsed the API host
345 // Wrap transport with GraphQLFeaturesTransport to inject feature flags from context,
346 // matching the transport chain used by the remote server.
347 gqlHTTPClient := &http.Client{
348 Transport: &transport.BearerAuthTransport{
349 Transport: &transport.GraphQLFeaturesTransport{
350 Transport: http.DefaultTransport,
351 },
352 Token: token,
353 },
354 }
355
356 graphqlURL, err := d.apiHosts.GraphqlURL(ctx)
357 if err != nil {
358 return nil, fmt.Errorf("failed to get GraphQL URL: %w", err)
359 }
360
361 gqlClient := githubv4.NewEnterpriseClient(graphqlURL.String(), gqlHTTPClient)
362 return gqlClient, nil
363}
364
365// GetRawClient implements ToolDependencies.
366func (d *RequestDeps) GetRawClient(ctx context.Context) (*raw.Client, error) {

Callers 1

GetRepoAccessCacheMethod · 0.95

Calls 2

GraphqlURLMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected