Skip to content

Commit d18f26e

Browse files
Add GraphQL-Features header support for agent assignment API
- Add context-based GraphQL feature flag support - Modify bearerAuthTransport to read features from context and add GraphQL-Features header - Use issues_copilot_assignment_api_support feature flag for updateIssue mutation - Export GetGraphQLFeatures function for use in HTTP transport layer This allows the assign_copilot_to_issue tool to work with the non-GA agent assignment API by sending the required GraphQL-Features header. Co-authored-by: SamMorrowDrums <[email protected]>
1 parent 88d117b commit d18f26e

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

internal/ghmcp/server.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,12 @@ type bearerAuthTransport struct {
622622
func (t *bearerAuthTransport) RoundTrip(req *http.Request) (*http.Response, error) {
623623
req = req.Clone(req.Context())
624624
req.Header.Set("Authorization", "Bearer "+t.token)
625+
626+
// Check for GraphQL-Features in context and add header if present
627+
if features := github.GetGraphQLFeatures(req.Context()); len(features) > 0 {
628+
req.Header.Set("GraphQL-Features", strings.Join(features, ", "))
629+
}
630+
625631
return t.transport.RoundTrip(req)
626632
}
627633

pkg/github/issues.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,8 @@ func AssignCopilotToIssue(t translations.TranslationHelperFunc) inventory.Server
17751775
agentAssignment.BaseRef = &baseRef
17761776
}
17771777

1778-
// Execute the updateIssue mutation
1778+
// Execute the updateIssue mutation with the GraphQL-Features header
1779+
// This header is required for the agent assignment API which is not GA yet
17791780
var updateIssueMutation struct {
17801781
UpdateIssue struct {
17811782
Issue struct {
@@ -1786,8 +1787,12 @@ func AssignCopilotToIssue(t translations.TranslationHelperFunc) inventory.Server
17861787
} `graphql:"updateIssue(input: $input)"`
17871788
}
17881789

1790+
// Add the GraphQL-Features header for the agent assignment API
1791+
// The header will be read by the HTTP transport if it's configured to do so
1792+
ctxWithFeatures := withGraphQLFeatures(ctx, "issues_copilot_assignment_api_support")
1793+
17891794
if err := client.Mutate(
1790-
ctx,
1795+
ctxWithFeatures,
17911796
&updateIssueMutation,
17921797
UpdateIssueInput{
17931798
ID: getIssueQuery.Repository.Issue.ID,
@@ -1908,3 +1913,19 @@ func AssignCodingAgentPrompt(t translations.TranslationHelperFunc) inventory.Ser
19081913
},
19091914
)
19101915
}
1916+
1917+
// graphQLFeaturesKey is a context key for GraphQL feature flags
1918+
type graphQLFeaturesKey struct{}
1919+
1920+
// withGraphQLFeatures adds GraphQL feature flags to the context
1921+
func withGraphQLFeatures(ctx context.Context, features ...string) context.Context {
1922+
return context.WithValue(ctx, graphQLFeaturesKey{}, features)
1923+
}
1924+
1925+
// GetGraphQLFeatures retrieves GraphQL feature flags from the context
1926+
func GetGraphQLFeatures(ctx context.Context) []string {
1927+
if features, ok := ctx.Value(graphQLFeaturesKey{}).([]string); ok {
1928+
return features
1929+
}
1930+
return nil
1931+
}

0 commit comments

Comments
 (0)