Skip to content

Commit e4c6b7a

Browse files
authored
Ensure that all collections are ordered. (#7946)
1 parent e4f2e9f commit e4c6b7a

File tree

47 files changed

+1209
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1209
-236
lines changed

src/HotChocolate/Fusion/src/Composition/FusionTypes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ private DirectiveDefinition RegisterSourceDirectiveType(string name, ScalarTypeD
306306

307307
public Directive CreateNodeDirective(string subgraphName, IReadOnlyCollection<ObjectTypeDefinition> types)
308308
{
309-
var temp = types.Select(t => new StringValueNode(t.Name)).ToArray();
309+
var temp = types.OrderBy(t => t.Name).Select(t => new StringValueNode(t.Name)).ToArray();
310310

311311
return new Directive(
312312
Node,

src/HotChocolate/Fusion/src/Composition/Pipeline/RemoveDirectivesWithoutLocationMiddleware.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
using HotChocolate.Skimmed;
2+
13
namespace HotChocolate.Fusion.Composition.Pipeline;
24

35
internal sealed class RemoveDirectivesWithoutLocationMiddleware : IMergeMiddleware
46
{
57
public async ValueTask InvokeAsync(CompositionContext context, MergeDelegate next)
68
{
9+
var removeDirectives = new List<DirectiveDefinition>();
10+
711
foreach(var directive in context.FusionGraph.DirectiveDefinitions)
812
{
913
if (context.FusionTypes.IsFusionDirective(directive.Name))
@@ -13,10 +17,17 @@ public async ValueTask InvokeAsync(CompositionContext context, MergeDelegate nex
1317

1418
if (directive.Locations == 0)
1519
{
16-
context.FusionGraph.DirectiveDefinitions.Remove(directive);
20+
removeDirectives.Add(directive);
1721
}
1822
}
1923

24+
foreach (var directive in removeDirectives)
25+
{
26+
context.FusionGraph.DirectiveDefinitions.Remove(directive);
27+
}
28+
29+
removeDirectives.Clear();
30+
2031
if (!context.Log.HasErrors)
2132
{
2233
await next(context).ConfigureAwait(false);

src/HotChocolate/Fusion/test/CommandLine.Tests/__snapshots__/ComposeCommandTests.Compose_Loose_Subgraph_Files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ schema @fusion(version: 1) @transport(subgraph: "accounts", group: "Fusion", loc
5555
type Query {
5656
userById(id: ID!): User @variable(subgraph: "accounts", name: "id", argument: "id") @resolver(subgraph: "accounts", select: "{ userById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
5757
userByName(name: String!): User @variable(subgraph: "accounts", name: "name", argument: "name") @resolver(subgraph: "accounts", select: "{ userByName(name: $name) }", arguments: [ { name: "name", type: "String!" } ])
58-
users(after: String before: String first: Int last: Int): UsersConnection @variable(subgraph: "accounts", name: "after", argument: "after") @variable(subgraph: "accounts", name: "before", argument: "before") @variable(subgraph: "accounts", name: "first", argument: "first") @variable(subgraph: "accounts", name: "last", argument: "last") @resolver(subgraph: "accounts", select: "{ users(after: $after, before: $before, first: $first, last: $last) }", arguments: [ { name: "after", type: "String" }, { name: "before", type: "String" }, { name: "first", type: "Int" }, { name: "last", type: "Int" } ])
58+
users(after: String before: String first: Int last: Int): UsersConnection @variable(subgraph: "accounts", name: "first", argument: "first") @variable(subgraph: "accounts", name: "after", argument: "after") @variable(subgraph: "accounts", name: "last", argument: "last") @variable(subgraph: "accounts", name: "before", argument: "before") @resolver(subgraph: "accounts", select: "{ users(first: $first, after: $after, last: $last, before: $before) }", arguments: [ { name: "first", type: "Int" }, { name: "after", type: "String" }, { name: "last", type: "Int" }, { name: "before", type: "String" } ])
5959
}
6060

6161
type PageInfo {

src/HotChocolate/Fusion/test/CommandLine.Tests/__snapshots__/ComposeCommandTests.Compose_With_Tag.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type Query {
5656
node(id: ID!): Node @variable(subgraph: "accounts", name: "id", argument: "id") @resolver(subgraph: "accounts", select: "{ node(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
5757
userById(id: ID!): User @variable(subgraph: "accounts", name: "id", argument: "id") @resolver(subgraph: "accounts", select: "{ userById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ])
5858
userByName(name: String!): User @variable(subgraph: "accounts", name: "name", argument: "name") @resolver(subgraph: "accounts", select: "{ userByName(name: $name) }", arguments: [ { name: "name", type: "String!" } ])
59-
users(after: String before: String first: Int last: Int): UsersConnection @variable(subgraph: "accounts", name: "after", argument: "after") @variable(subgraph: "accounts", name: "before", argument: "before") @variable(subgraph: "accounts", name: "first", argument: "first") @variable(subgraph: "accounts", name: "last", argument: "last") @resolver(subgraph: "accounts", select: "{ users(after: $after, before: $before, first: $first, last: $last) }", arguments: [ { name: "after", type: "String" }, { name: "before", type: "String" }, { name: "first", type: "Int" }, { name: "last", type: "Int" } ])
59+
users(after: String before: String first: Int last: Int): UsersConnection @variable(subgraph: "accounts", name: "first", argument: "first") @variable(subgraph: "accounts", name: "after", argument: "after") @variable(subgraph: "accounts", name: "last", argument: "last") @variable(subgraph: "accounts", name: "before", argument: "before") @resolver(subgraph: "accounts", select: "{ users(first: $first, after: $after, last: $last, before: $before) }", arguments: [ { name: "first", type: "Int" }, { name: "after", type: "String" }, { name: "last", type: "Int" }, { name: "before", type: "String" } ])
6060
}
6161

6262
type PageInfo {

src/HotChocolate/Fusion/test/Composition.Tests/__snapshots__/DemoIntegrationTests.Accounts_And_Reviews2_Products_With_Nodes.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ schema
77
@transport(subgraph: "Products", location: "http:\/\/localhost:5000\/graphql", kind: "HTTP")
88
@transport(subgraph: "Products", location: "ws:\/\/localhost:5000\/graphql", kind: "WebSocket")
99
@node(subgraph: "Accounts", types: [ "User" ])
10-
@node(subgraph: "Reviews2", types: [ "User", "Review" ])
11-
@node(subgraph: "Products", types: [ "ProductConfiguration", "Product", "ProductBookmark" ]) {
10+
@node(subgraph: "Reviews2", types: [ "Review", "User" ])
11+
@node(subgraph: "Products", types: [ "Product", "ProductBookmark", "ProductConfiguration" ]) {
1212
query: Query
1313
mutation: Mutation
1414
subscription: Subscription

src/HotChocolate/Fusion/test/Composition.Tests/__snapshots__/DemoIntegrationTests.Accounts_And_Reviews_Products_With_Nodes.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ schema
77
@transport(subgraph: "Products", location: "http:\/\/localhost:5000\/graphql", kind: "HTTP")
88
@transport(subgraph: "Products", location: "ws:\/\/localhost:5000\/graphql", kind: "WebSocket")
99
@node(subgraph: "Accounts", types: [ "User" ])
10-
@node(subgraph: "Reviews", types: [ "User", "Review" ])
11-
@node(subgraph: "Products", types: [ "ProductConfiguration", "Product", "ProductBookmark" ]) {
10+
@node(subgraph: "Reviews", types: [ "Review", "User" ])
11+
@node(subgraph: "Products", types: [ "Product", "ProductBookmark", "ProductConfiguration" ]) {
1212
query: Query
1313
mutation: Mutation
1414
subscription: Subscription

src/HotChocolate/Fusion/test/Composition.Tests/__snapshots__/DemoIntegrationTests.Compose_With_SourceSchema_Lib.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ type Product implements Node
114114
deliveryEstimate(zip: String!): DeliveryEstimate!
115115
@source(subgraph: "Shipping2")
116116
@variable(subgraph: "Shipping2", name: "zip", argument: "zip")
117-
@variable(subgraph: "Products", name: "Product_dimension_size", select: "dimension { size }")
118117
@variable(subgraph: "Products", name: "Product_dimension_weight", select: "dimension { weight }")
119-
@resolver(subgraph: "Shipping2", select: "{ deliveryEstimate(size: $Product_dimension_size, weight: $Product_dimension_weight, zip: $zip) }", arguments: [ { name: "Product_dimension_size", type: "Int!" }, { name: "Product_dimension_weight", type: "Int!" }, { name: "zip", type: "String!" } ])
118+
@variable(subgraph: "Products", name: "Product_dimension_size", select: "dimension { size }")
119+
@resolver(subgraph: "Shipping2", select: "{ deliveryEstimate(weight: $Product_dimension_weight, size: $Product_dimension_size, zip: $zip) }", arguments: [ { name: "Product_dimension_weight", type: "Int!" }, { name: "Product_dimension_size", type: "Int!" }, { name: "zip", type: "String!" } ])
120120
dimension: ProductDimension!
121121
@source(subgraph: "Products")
122122
id: ID!

src/HotChocolate/Fusion/test/Composition.Tests/__snapshots__/RequireTests.Require_Scalar_Arguments_No_Overloads.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ type Product implements Node
116116
deliveryEstimate(zip: String!): DeliveryEstimate!
117117
@source(subgraph: "Shipping")
118118
@variable(subgraph: "Shipping", name: "zip", argument: "zip")
119-
@variable(subgraph: "Products", name: "Product_dimension_size", select: "dimension { size }")
120119
@variable(subgraph: "Products", name: "Product_dimension_weight", select: "dimension { weight }")
121-
@resolver(subgraph: "Shipping", select: "{ deliveryEstimate(size: $Product_dimension_size, weight: $Product_dimension_weight, zip: $zip) }", arguments: [ { name: "Product_dimension_size", type: "Int!" }, { name: "Product_dimension_weight", type: "Int!" }, { name: "zip", type: "String!" } ])
120+
@variable(subgraph: "Products", name: "Product_dimension_size", select: "dimension { size }")
121+
@resolver(subgraph: "Shipping", select: "{ deliveryEstimate(weight: $Product_dimension_weight, size: $Product_dimension_size, zip: $zip) }", arguments: [ { name: "Product_dimension_weight", type: "Int!" }, { name: "Product_dimension_size", type: "Int!" }, { name: "zip", type: "String!" } ])
122122
dimension: ProductDimension!
123123
@source(subgraph: "Products")
124124
id: ID!

src/HotChocolate/Fusion/test/Composition.Tests/__snapshots__/ResolverCompositionTests.Ensure_Node_Resolver_Only_Picked_If_Needed.graphql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ type Query {
1212
@variable(subgraph: "A", name: "username", argument: "username")
1313
@resolver(subgraph: "A", select: "{ userByUsername(username: $username) }", arguments: [ { name: "username", type: "String!" } ])
1414
users(after: String before: String first: Int last: Int): UsersConnection
15-
@variable(subgraph: "A", name: "after", argument: "after")
16-
@variable(subgraph: "A", name: "before", argument: "before")
1715
@variable(subgraph: "A", name: "first", argument: "first")
16+
@variable(subgraph: "A", name: "after", argument: "after")
1817
@variable(subgraph: "A", name: "last", argument: "last")
19-
@resolver(subgraph: "A", select: "{ users(after: $after, before: $before, first: $first, last: $last) }", arguments: [ { name: "after", type: "String" }, { name: "before", type: "String" }, { name: "first", type: "Int" }, { name: "last", type: "Int" } ])
18+
@variable(subgraph: "A", name: "before", argument: "before")
19+
@resolver(subgraph: "A", select: "{ users(first: $first, after: $after, last: $last, before: $before) }", arguments: [ { name: "first", type: "Int" }, { name: "after", type: "String" }, { name: "last", type: "Int" }, { name: "before", type: "String" } ])
2020
}
2121

2222
type PageInfo {

src/HotChocolate/Fusion/test/Composition.Tests/__snapshots__/ResolverCompositionTests.Merge_Meta_Data_Correctly.graphql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ type Query {
1212
@variable(subgraph: "A", name: "username", argument: "username")
1313
@resolver(subgraph: "A", select: "{ userByUsername(username: $username) }", arguments: [ { name: "username", type: "String!" } ])
1414
users(after: String before: String first: Int last: Int): UsersConnection
15-
@variable(subgraph: "A", name: "after", argument: "after")
16-
@variable(subgraph: "A", name: "before", argument: "before")
1715
@variable(subgraph: "A", name: "first", argument: "first")
16+
@variable(subgraph: "A", name: "after", argument: "after")
1817
@variable(subgraph: "A", name: "last", argument: "last")
19-
@resolver(subgraph: "A", select: "{ users(after: $after, before: $before, first: $first, last: $last) }", arguments: [ { name: "after", type: "String" }, { name: "before", type: "String" }, { name: "first", type: "Int" }, { name: "last", type: "Int" } ])
18+
@variable(subgraph: "A", name: "before", argument: "before")
19+
@resolver(subgraph: "A", select: "{ users(first: $first, after: $after, last: $last, before: $before) }", arguments: [ { name: "first", type: "Int" }, { name: "after", type: "String" }, { name: "last", type: "Int" }, { name: "before", type: "String" } ])
2020
}
2121

2222
type PageInfo {

0 commit comments

Comments
 (0)