GetGQLClient implements ToolDependencies.
(ctx context.Context)
| 333 | |
| 334 | // GetGQLClient implements ToolDependencies. |
| 335 | func (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. |
| 366 | func (d *RequestDeps) GetRawClient(ctx context.Context) (*raw.Client, error) { |
no test coverage detected