agent_patch
runs/2026-02-21__03-36-16__gpt-5-1-codex-mini/flux-pr-1380/flux-pr-1380.1-of-1.2026-03-05__17-48-26__gpt-5-1-codex-mini/agent-logs/agent.patch
6084 bytes
diff --git a/tmp/agent-patch-flux-pr-1380.1-of-1.2026-03-05__17-48-26__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/graphql_datasource/graphql_datasource_federation_test.go b/app/v2/pkg/engine/datasource/graphql_datasource/graphql_datasource_federation_test.go
index 3c97139..4e4836a 100644
--- a/tmp/agent-patch-flux-pr-1380.1-of-1.2026-03-05__17-48-26__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/graphql_datasource/graphql_datasource_federation_test.go
+++ b/app/v2/pkg/engine/datasource/graphql_datasource/graphql_datasource_federation_test.go
@@ -3,7 +3,14 @@ package graphql_datasource
import (
"testing"
+ "github.com/stretchr/testify/require"
+
"github.com/wundergraph/graphql-go-tools/v2/pkg/ast"
+ "github.com/wundergraph/graphql-go-tools/v2/pkg/astnormalization"
+ "github.com/wundergraph/graphql-go-tools/v2/pkg/asttransform"
+ "github.com/wundergraph/graphql-go-tools/v2/pkg/astvalidation"
+ "github.com/wundergraph/graphql-go-tools/v2/pkg/operationreport"
+ "github.com/wundergraph/graphql-go-tools/v2/pkg/internal/unsafeparser"
. "github.com/wundergraph/graphql-go-tools/v2/pkg/engine/datasourcetesting"
"github.com/wundergraph/graphql-go-tools/v2/pkg/engine/plan"
"github.com/wundergraph/graphql-go-tools/v2/pkg/engine/postprocess"
@@ -4394,6 +4401,160 @@ func TestGraphQLDataSourceFederation(t *testing.T) {
)
})
+ t.Run("requires provided by upstream provides", func(t *testing.T) {
+ definition := `
+ type Query {
+ me: User
+ }
+
+ type User @key(fields: "id") {
+ id: ID!
+ address: Address
+ }
+
+ type Address @key(fields: "id") {
+ id: ID!
+ street: String!
+ zip: String!
+ }
+ `
+
+ userSubgraphSDL := `
+ type Query {
+ me: User @provides(fields: "address { street zip }")
+ }
+
+ type User @key(fields: "id") {
+ id: ID!
+ address: Address
+ }
+
+ type Address @key(fields: "id") {
+ id: ID!
+ street: String! @external
+ zip: String! @external
+ }
+ `
+
+ addressSubgraphSDL := `
+ type Address @key(fields: "id") {
+ id: ID!
+ street: String! @requires(fields: "zip")
+ zip: String! @external
+ }
+ `
+
+ userDataSource := mustDataSourceConfiguration(
+ t,
+ "user.service",
+ &plan.DataSourceMetadata{
+ RootNodes: []plan.TypeField{
+ {TypeName: "Query", FieldNames: []string{"me"}},
+ {TypeName: "User", FieldNames: []string{"id", "address"}},
+ {TypeName: "Address", FieldNames: []string{"id", "street", "zip"}},
+ },
+ FederationMetaData: plan.FederationMetaData{
+ Keys: plan.FederationFieldConfigurations{
+ {TypeName: "User", SelectionSet: "id"},
+ {TypeName: "Address", SelectionSet: "id"},
+ },
+ Provides: plan.FederationFieldConfigurations{
+ {
+ TypeName: "Query",
+ FieldName: "me",
+ SelectionSet: "address { street zip }",
+ },
+ },
+ },
+ },
+ mustCustomConfiguration(t,
+ ConfigurationInput{
+ Fetch: &FetchConfiguration{URL: "http://user.service"},
+ SchemaConfiguration: mustSchema(t,
+ &FederationConfiguration{Enabled: true, ServiceSDL: userSubgraphSDL},
+ userSubgraphSDL,
+ ),
+ },
+ ),
+ )
+
+ addressDataSource := mustDataSourceConfiguration(
+ t,
+ "address.service",
+ &plan.DataSourceMetadata{
+ RootNodes: []plan.TypeField{
+ {TypeName: "Address", FieldNames: []string{"id", "street"}},
+ },
+ FederationMetaData: plan.FederationMetaData{
+ Keys: plan.FederationFieldConfigurations{
+ {TypeName: "Address", SelectionSet: "id"},
+ },
+ Requires: plan.FederationFieldConfigurations{
+ {TypeName: "Address", FieldName: "street", SelectionSet: "zip"},
+ },
+ },
+ },
+ mustCustomConfiguration(t,
+ ConfigurationInput{
+ Fetch: &FetchConfiguration{URL: "http://address.service"},
+ SchemaConfiguration: mustSchema(t,
+ &FederationConfiguration{Enabled: true, ServiceSDL: addressSubgraphSDL},
+ addressSubgraphSDL,
+ ),
+ },
+ ),
+ )
+
+ planConfiguration := plan.Configuration{
+ DataSources: []plan.DataSource{userDataSource, addressDataSource},
+ DisableResolveFieldPositions: true,
+ }
+
+ operation := `
+ query RequiresProvided {
+ me {
+ address {
+ street
+ }
+ }
+ }`
+
+ operationName := "RequiresProvided"
+
+ opDoc := unsafeparser.ParseGraphqlDocumentString(operation)
+ defDoc := unsafeparser.ParseGraphqlDocumentString(definition)
+
+ var report operationreport.Report
+ err := asttransform.MergeDefinitionWithBaseSchema(&defDoc)
+ require.NoError(t, err)
+
+ norm := astnormalization.NewWithOpts(astnormalization.WithExtractVariables(), astnormalization.WithInlineFragmentSpreads(), astnormalization.WithRemoveFragmentDefinitions(), astnormalization.WithRemoveUnusedVariables())
+ norm.NormalizeOperation(&opDoc, &defDoc, &report)
+
+ validator := astvalidation.DefaultOperationValidator()
+ validator.Validate(&opDoc, &defDoc, &report)
+ require.False(t, report.HasErrors())
+
+ planner, err := plan.NewPlanner(planConfiguration)
+ require.NoError(t, err)
+
+ planned := planner.Plan(&opDoc, &defDoc, operationName, &report)
+ require.False(t, report.HasErrors())
+
+ syncPlan, ok := planned.(*plan.SynchronousResponsePlan)
+ require.True(t, ok)
+
+ require.Len(t, syncPlan.Response.RawFetches, 1)
+ fetchItem := syncPlan.Response.RawFetches[0]
+ singleFetch, ok := fetchItem.Fetch.(*resolve.SingleFetch)
+ require.True(t, ok)
+ fetchInput := string(singleFetch.FetchConfiguration.Input)
+ require.Contains(t, fetchInput, "\"me\"")
+ require.Contains(t, fetchInput, "address")
+ require.Contains(t, fetchInput, "street")
+ require.Contains(t, fetchInput, "zip")
+ })
+
t.Run("requires fields from the root query subgraph", func(t *testing.T) {
definition := `
type User {