File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -1914,15 +1914,22 @@ func AssignCodingAgentPrompt(t translations.TranslationHelperFunc) inventory.Ser
19141914 )
19151915}
19161916
1917- // graphQLFeaturesKey is a context key for GraphQL feature flags
1917+ // graphQLFeaturesKey is a context key for GraphQL feature flags.
1918+ // These flags enable preview or experimental GitHub API features that are not yet GA.
19181919type graphQLFeaturesKey struct {}
19191920
1920- // withGraphQLFeatures adds GraphQL feature flags to the context
1921+ // withGraphQLFeatures adds GraphQL feature flags to the context.
1922+ // The flags are read by GraphQLFeaturesTransport and sent as the GraphQL-Features header.
1923+ // This is used internally by tool handlers that require experimental GitHub API features.
19211924func withGraphQLFeatures (ctx context.Context , features ... string ) context.Context {
19221925 return context .WithValue (ctx , graphQLFeaturesKey {}, features )
19231926}
19241927
1925- // GetGraphQLFeatures retrieves GraphQL feature flags from the context
1928+ // GetGraphQLFeatures retrieves GraphQL feature flags from the context.
1929+ // This function is exported to allow custom HTTP transports (e.g., in remote servers)
1930+ // to read feature flags and add them as the "GraphQL-Features" header.
1931+ //
1932+ // For most use cases, use GraphQLFeaturesTransport instead of calling this directly.
19261933func GetGraphQLFeatures (ctx context.Context ) []string {
19271934 if features , ok := ctx .Value (graphQLFeaturesKey {}).([]string ); ok {
19281935 return features
Original file line number Diff line number Diff line change @@ -10,15 +10,32 @@ import (
1010//
1111// This transport should be used in the HTTP client chain for githubv4.Client
1212// to ensure GraphQL feature flags are properly sent to the GitHub API.
13+ // Without this transport, certain GitHub API features (like Copilot assignment)
14+ // that require feature flags will fail with schema validation errors.
1315//
14- // Example usage:
16+ // Example usage for local server (layering with auth):
17+ //
18+ // httpClient := &http.Client{
19+ // Transport: &github.GraphQLFeaturesTransport{
20+ // Transport: &authTransport{
21+ // Transport: http.DefaultTransport,
22+ // token: "ghp_...",
23+ // },
24+ // },
25+ // }
26+ // gqlClient := githubv4.NewClient(httpClient)
27+ //
28+ // Example usage for remote server (simple case):
1529//
1630// httpClient := &http.Client{
1731// Transport: &github.GraphQLFeaturesTransport{
1832// Transport: http.DefaultTransport,
1933// },
2034// }
2135// gqlClient := githubv4.NewClient(httpClient)
36+ //
37+ // The transport reads feature flags from request context using GetGraphQLFeatures.
38+ // Feature flags are added to context by the tool handler via withGraphQLFeatures.
2239type GraphQLFeaturesTransport struct {
2340 // Transport is the underlying http.RoundTripper. If nil, http.DefaultTransport is used.
2441 Transport http.RoundTripper
You can’t perform that action at this time.
0 commit comments