Skip to content

Commit 7333546

Browse files
Move GraphQL features functions to transport.go
Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
1 parent fc95d3e commit 7333546

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

pkg/github/issues.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,26 +1913,3 @@ func AssignCodingAgentPrompt(t translations.TranslationHelperFunc) inventory.Ser
19131913
},
19141914
)
19151915
}
1916-
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.
1919-
type graphQLFeaturesKey struct{}
1920-
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.
1924-
func withGraphQLFeatures(ctx context.Context, features ...string) context.Context {
1925-
return context.WithValue(ctx, graphQLFeaturesKey{}, features)
1926-
}
1927-
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.
1933-
func GetGraphQLFeatures(ctx context.Context) []string {
1934-
if features, ok := ctx.Value(graphQLFeaturesKey{}).([]string); ok {
1935-
return features
1936-
}
1937-
return nil
1938-
}

pkg/github/transport.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
11
package github
22

33
import (
4+
"context"
45
"net/http"
56
"strings"
67
)
78

9+
// graphQLFeaturesKey is a context key for GraphQL feature flags.
10+
// These flags enable preview or experimental GitHub API features that are not yet GA.
11+
type graphQLFeaturesKey struct{}
12+
13+
// withGraphQLFeatures adds GraphQL feature flags to the context.
14+
// The flags are read by GraphQLFeaturesTransport and sent as the GraphQL-Features header.
15+
// This is used internally by tool handlers that require experimental GitHub API features.
16+
func withGraphQLFeatures(ctx context.Context, features ...string) context.Context {
17+
return context.WithValue(ctx, graphQLFeaturesKey{}, features)
18+
}
19+
20+
// GetGraphQLFeatures retrieves GraphQL feature flags from the context.
21+
// This function is exported to allow custom HTTP transports (e.g., in remote servers)
22+
// to read feature flags and add them as the "GraphQL-Features" header.
23+
//
24+
// For most use cases, use GraphQLFeaturesTransport instead of calling this directly.
25+
func GetGraphQLFeatures(ctx context.Context) []string {
26+
if features, ok := ctx.Value(graphQLFeaturesKey{}).([]string); ok {
27+
return features
28+
}
29+
return nil
30+
}
31+
832
// GraphQLFeaturesTransport is an http.RoundTripper that adds GraphQL-Features
933
// header based on context values set by withGraphQLFeatures.
1034
//

0 commit comments

Comments
 (0)