diff --git a/router-tests/go.mod b/router-tests/go.mod index 750be3052..a8b938651 100644 --- a/router-tests/go.mod +++ b/router-tests/go.mod @@ -31,7 +31,7 @@ require ( github.com/wundergraph/cosmo/router v0.0.0-20260710155145-803a4bc06d92 github.com/wundergraph/cosmo/router-plugin v0.0.0-20250808194725-de123ba1c65e github.com/wundergraph/cosmo/speedtrap v0.0.0-00010101000000-000000000000 - github.com/wundergraph/graphql-go-tools/v2 v2.13.2 + github.com/wundergraph/graphql-go-tools/v2 v2.14.1 go.opentelemetry.io/otel v1.44.0 go.opentelemetry.io/otel/sdk v1.44.0 go.opentelemetry.io/otel/sdk/metric v1.44.0 diff --git a/router-tests/go.sum b/router-tests/go.sum index 47c81c0d8..8f0aea41c 100644 --- a/router-tests/go.sum +++ b/router-tests/go.sum @@ -386,8 +386,8 @@ github.com/wundergraph/astjson v1.1.0 h1:xORDosrZ87zQFJwNGe/HIHXqzpdHOFmqWgykCLV github.com/wundergraph/astjson v1.1.0/go.mod h1:h12D/dxxnedtLzsKyBLK7/Oe4TAoGpRVC9nDpDrZSWw= github.com/wundergraph/go-arena v1.3.0 h1:n0ng5a1vbd8YGq1u3rMr0vPU5f6AZ1BXIiUhL1UIok8= github.com/wundergraph/go-arena v1.3.0/go.mod h1:ROOysEHWJjLQ8FSfNxZCziagb7Qw2nXY3/vgKRh7eWw= -github.com/wundergraph/graphql-go-tools/v2 v2.13.2 h1:YbK0HRgqoYNrlaFJDxST2+G9zex6okKLtjgDXNeVd48= -github.com/wundergraph/graphql-go-tools/v2 v2.13.2/go.mod h1:zREIKLmpjfNcGSubndaW/913r0Y8XbbYOXQeZFkwHdo= +github.com/wundergraph/graphql-go-tools/v2 v2.14.1 h1:TecnvTyhskoeiqo6W+1xh7HqAPL/RG5vfbFhezu7RLs= +github.com/wundergraph/graphql-go-tools/v2 v2.14.1/go.mod h1:zREIKLmpjfNcGSubndaW/913r0Y8XbbYOXQeZFkwHdo= github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg= github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4= diff --git a/router-tests/protocol/grpc_subgraph_test.go b/router-tests/protocol/grpc_subgraph_test.go index 47ea8e028..71c18cb59 100644 --- a/router-tests/protocol/grpc_subgraph_test.go +++ b/router-tests/protocol/grpc_subgraph_test.go @@ -310,6 +310,11 @@ func TestGRPCSubgraph(t *testing.T) { query: `{ employee(id: 1) { id taggedProjectSummary } }`, expected: `{"data":{"employee":{"id":1,"taggedProjectSummary":"expertise: Backend Architecture, project tags: [cloud, migration, priority, devops, ci-cd, infrastructure]"}}}`, }, + { + name: "query employee @requires field resolved with expertise and aliased", + query: `{ employee(id: 1) { id preAlias: taggedProjectSummary taggedProjectSummary aliasedTaggedProjectSummary: taggedProjectSummary } }`, + expected: `{"data":{"employee":{"id":1,"preAlias":"expertise: Backend Architecture, project tags: [cloud, migration, priority, devops, ci-cd, infrastructure]","taggedProjectSummary":"expertise: Backend Architecture, project tags: [cloud, migration, priority, devops, ci-cd, infrastructure]","aliasedTaggedProjectSummary":"expertise: Backend Architecture, project tags: [cloud, migration, priority, devops, ci-cd, infrastructure]"}}}`, + }, { name: "query employee @requires field resolved with expertise (employee 2)", query: `{ employee(id: 2) { id taggedProjectSummary } }`, @@ -352,6 +357,11 @@ func TestGRPCSubgraph(t *testing.T) { query: `{ employee(id: 2) { id reviewReport } }`, expected: `{"data":{"employee":{"id":2,"reviewReport":"Rejected: Needs more documentation (code: DOC_001)"}}}`, }, + { + name: "query employee @requires flat union aliased (approval)", + query: `{ employee(id: 1) { id aliasedReviewReport: reviewReport } }`, + expected: `{"data":{"employee":{"id":1,"aliasedReviewReport":"Approved: Excellent work on the API at 2024-01-15"}}}`, + }, // Pattern 3: Concrete wrapping abstract { name: "query employee @requires concrete wrapping abstract (technical)", @@ -396,12 +406,22 @@ func TestGRPCSubgraph(t *testing.T) { query: `{ employee(id: 2) { id deepWorkItemInfo } }`, expected: `{"data":{"employee":{"id":2,"deepWorkItemInfo":"ManagementHandler: Bob Lead"}}}`, }, + { + name: "query employee @requires aliased nested abstract through concrete (management deep)", + query: `{ employee(id: 2) { id aliasedDeepWorkItemInfo: deepWorkItemInfo } }`, + expected: `{"data":{"employee":{"id":2,"aliasedDeepWorkItemInfo":"ManagementHandler: Bob Lead"}}}`, + }, // Non-existent employee with composite @requires fields { name: "query non-existent employee with @requires composite fields returns null", query: `{ employee(id: 999) { id workItemInfo reviewReport } }`, expected: `{"data":{"employee":null}}`, }, + { + name: "query non-existent employee with @requires and aliased fields returns null", + query: `{ employee(id: 999) { id workItemInfo reviewReport aliasedReviewReport: reviewReport } }`, + expected: `{"data":{"employee":null}}`, + }, } testenv.Run(t, &testenv.Config{ RouterConfigJSONTemplate: testenv.ConfigWithGRPCJSONTemplate, diff --git a/router/go.mod b/router/go.mod index da4874942..0a51e0aa8 100644 --- a/router/go.mod +++ b/router/go.mod @@ -31,7 +31,7 @@ require ( github.com/tidwall/gjson v1.18.0 github.com/tidwall/sjson v1.2.5 github.com/twmb/franz-go v1.16.1 - github.com/wundergraph/graphql-go-tools/v2 v2.13.2 + github.com/wundergraph/graphql-go-tools/v2 v2.14.1 // Do not upgrade, it renames attributes we rely on go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.68.0 go.opentelemetry.io/contrib/propagators/b3 v1.44.0 diff --git a/router/go.sum b/router/go.sum index 14440de71..f9cb5d523 100644 --- a/router/go.sum +++ b/router/go.sum @@ -334,8 +334,8 @@ github.com/wundergraph/astjson v1.1.0 h1:xORDosrZ87zQFJwNGe/HIHXqzpdHOFmqWgykCLV github.com/wundergraph/astjson v1.1.0/go.mod h1:h12D/dxxnedtLzsKyBLK7/Oe4TAoGpRVC9nDpDrZSWw= github.com/wundergraph/go-arena v1.3.0 h1:n0ng5a1vbd8YGq1u3rMr0vPU5f6AZ1BXIiUhL1UIok8= github.com/wundergraph/go-arena v1.3.0/go.mod h1:ROOysEHWJjLQ8FSfNxZCziagb7Qw2nXY3/vgKRh7eWw= -github.com/wundergraph/graphql-go-tools/v2 v2.13.2 h1:YbK0HRgqoYNrlaFJDxST2+G9zex6okKLtjgDXNeVd48= -github.com/wundergraph/graphql-go-tools/v2 v2.13.2/go.mod h1:zREIKLmpjfNcGSubndaW/913r0Y8XbbYOXQeZFkwHdo= +github.com/wundergraph/graphql-go-tools/v2 v2.14.1 h1:TecnvTyhskoeiqo6W+1xh7HqAPL/RG5vfbFhezu7RLs= +github.com/wundergraph/graphql-go-tools/v2 v2.14.1/go.mod h1:zREIKLmpjfNcGSubndaW/913r0Y8XbbYOXQeZFkwHdo= github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4= github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4= github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=