Skip to content

Commit 5ca1d87

Browse files
Updated Entities in Entity Resolver error tests to implement Node interface (#7350)
1 parent 28185fd commit 5ca1d87

8 files changed

+485
-170
lines changed

src/HotChocolate/Fusion/test/Core.Tests/SubgraphErrorTests.cs

Lines changed: 206 additions & 50 deletions
Large diffs are not rendered by default.

src/HotChocolate/Fusion/test/Core.Tests/TransportErrorTests.cs

Lines changed: 96 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,15 @@ type Query {
414414
productById(id: ID!): Product
415415
}
416416
417-
type Product {
418-
id: ID
417+
type Product implements Node {
418+
id: ID!
419419
name: String
420420
price: Float
421421
}
422+
423+
interface Node {
424+
id: ID!
425+
}
422426
""",
423427
isOffline: true);
424428

@@ -451,11 +455,15 @@ type Query {
451455
productById(id: ID!): Product!
452456
}
453457
454-
type Product {
455-
id: ID
458+
type Product implements Node {
459+
id: ID!
456460
name: String
457461
price: Float
458462
}
463+
464+
interface Node {
465+
id: ID!
466+
}
459467
""",
460468
isOffline: true);
461469

@@ -488,11 +496,15 @@ type Query {
488496
productById(id: ID!): Product
489497
}
490498
491-
type Product {
492-
id: ID
499+
type Product implements Node {
500+
id: ID!
493501
name: String
494502
price: Float
495503
}
504+
505+
interface Node {
506+
id: ID!
507+
}
496508
""",
497509
isOffline: true);
498510

@@ -502,10 +514,14 @@ type Query {
502514
productById(id: ID!): Product
503515
}
504516
505-
type Product {
506-
id: ID
517+
type Product implements Node {
518+
id: ID!
507519
score: Int
508520
}
521+
522+
interface Node {
523+
id: ID!
524+
}
509525
""");
510526

511527
using var subgraphs = new TestSubgraphCollection(output, [subgraphA, subgraphB]);
@@ -538,11 +554,15 @@ type Query {
538554
productById(id: ID!): Product
539555
}
540556
541-
type Product {
557+
type Product implements Node {
542558
id: ID!
543559
name: String!
544560
price: Float!
545561
}
562+
563+
interface Node {
564+
id: ID!
565+
}
546566
""",
547567
isOffline: true);
548568

@@ -552,10 +572,14 @@ type Query {
552572
productById(id: ID!): Product
553573
}
554574
555-
type Product {
575+
type Product implements Node {
556576
id: ID!
557577
score: Int!
558578
}
579+
580+
interface Node {
581+
id: ID!
582+
}
559583
""");
560584

561585
using var subgraphs = new TestSubgraphCollection(output, [subgraphA, subgraphB]);
@@ -588,11 +612,15 @@ type Query {
588612
productById(id: ID!): Product!
589613
}
590614
591-
type Product {
615+
type Product implements Node {
592616
id: ID!
593617
name: String!
594618
price: Float!
595619
}
620+
621+
interface Node {
622+
id: ID!
623+
}
596624
""",
597625
isOffline: true);
598626

@@ -602,10 +630,14 @@ type Query {
602630
productById(id: ID!): Product!
603631
}
604632
605-
type Product {
633+
type Product implements Node {
606634
id: ID!
607635
score: Int!
608636
}
637+
638+
interface Node {
639+
id: ID!
640+
}
609641
""");
610642

611643
using var subgraphs = new TestSubgraphCollection(output, [subgraphA, subgraphB]);
@@ -638,11 +670,15 @@ type Query {
638670
productById(id: ID!): Product
639671
}
640672
641-
type Product {
642-
id: ID
673+
type Product implements Node {
674+
id: ID!
643675
name: String
644676
price: Float
645677
}
678+
679+
interface Node {
680+
id: ID!
681+
}
646682
""");
647683

648684
var subgraphB = await TestSubgraph.CreateAsync(
@@ -651,10 +687,14 @@ type Query {
651687
productById(id: ID!): Product
652688
}
653689
654-
type Product {
655-
id: ID
690+
type Product implements Node {
691+
id: ID!
656692
score: Int
657693
}
694+
695+
interface Node {
696+
id: ID!
697+
}
658698
""",
659699
isOffline: true);
660700

@@ -688,11 +728,15 @@ type Query {
688728
productById(id: ID!): Product
689729
}
690730
691-
type Product {
731+
type Product implements Node {
692732
id: ID!
693733
name: String!
694734
price: Float!
695735
}
736+
737+
interface Node {
738+
id: ID!
739+
}
696740
""");
697741

698742
var subgraphB = await TestSubgraph.CreateAsync(
@@ -701,10 +745,14 @@ type Query {
701745
productById(id: ID!): Product
702746
}
703747
704-
type Product {
748+
type Product implements Node {
705749
id: ID!
706750
score: Int!
707751
}
752+
753+
interface Node {
754+
id: ID!
755+
}
708756
""",
709757
isOffline: true);
710758

@@ -738,11 +786,15 @@ type Query {
738786
productById(id: ID!): Product!
739787
}
740788
741-
type Product {
789+
type Product implements Node {
742790
id: ID!
743791
name: String!
744792
price: Float!
745793
}
794+
795+
interface Node {
796+
id: ID!
797+
}
746798
""");
747799

748800
var subgraphB = await TestSubgraph.CreateAsync(
@@ -751,10 +803,14 @@ type Query {
751803
productById(id: ID!): Product!
752804
}
753805
754-
type Product {
806+
type Product implements Node {
755807
id: ID!
756808
score: Int!
757809
}
810+
811+
interface Node {
812+
id: ID!
813+
}
758814
""",
759815
isOffline: true);
760816

@@ -788,11 +844,15 @@ type Query {
788844
productById(id: ID!): Product
789845
}
790846
791-
type Product {
847+
type Product implements Node {
792848
id: ID!
793849
name: String!
794850
price: Float!
795851
}
852+
853+
interface Node {
854+
id: ID!
855+
}
796856
""",
797857
isOffline: true);
798858

@@ -802,10 +862,14 @@ type Query {
802862
productById(id: ID!): Product
803863
}
804864
805-
type Product {
865+
type Product implements Node {
806866
id: ID!
807867
score: Int!
808868
}
869+
870+
interface Node {
871+
id: ID!
872+
}
809873
""",
810874
isOffline: true);
811875

@@ -839,11 +903,15 @@ type Query {
839903
productById(id: ID!): Product!
840904
}
841905
842-
type Product {
906+
type Product implements Node {
843907
id: ID!
844908
name: String!
845909
price: Float!
846910
}
911+
912+
interface Node {
913+
id: ID!
914+
}
847915
""",
848916
isOffline: true);
849917

@@ -853,10 +921,14 @@ type Query {
853921
productById(id: ID!): Product!
854922
}
855923
856-
type Product {
924+
type Product implements Node {
857925
id: ID!
858926
score: Int!
859927
}
928+
929+
interface Node {
930+
id: ID!
931+
}
860932
""",
861933
isOffline: true);
862934

src/HotChocolate/Fusion/test/Core.Tests/__snapshots__/SubgraphErrorTests.Entity_Resolver_SubField_Nullable_EntryField_Nullable_First_Service_Errors_EntryField.md

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@
1919
}
2020
],
2121
"data": {
22-
"productById": {
23-
"id": null,
24-
"name": null,
25-
"price": null,
26-
"score": 123
27-
}
22+
"productById": null
2823
}
2924
}
3025
```
@@ -45,7 +40,7 @@
4540
## QueryPlan Hash
4641

4742
```text
48-
1187C75DB20A2D54D1EDC1F31D46DA85C597E294
43+
A5FE502D9F6F0548B898BC17A33BC0F2A2A13AE6
4944
```
5045

5146
## QueryPlan
@@ -57,19 +52,13 @@
5752
"type": "Sequence",
5853
"nodes": [
5954
{
60-
"type": "Parallel",
61-
"nodes": [
62-
{
63-
"type": "Resolve",
64-
"subgraph": "Subgraph_1",
65-
"document": "query fetch_productById_1 { productById(id: \u00221\u0022) { id name price } }",
66-
"selectionSetId": 0
67-
},
55+
"type": "Resolve",
56+
"subgraph": "Subgraph_1",
57+
"document": "query fetch_productById_1 { productById(id: \u00221\u0022) { id name price __fusion_exports__1: id } }",
58+
"selectionSetId": 0,
59+
"provides": [
6860
{
69-
"type": "Resolve",
70-
"subgraph": "Subgraph_2",
71-
"document": "query fetch_productById_2 { productById(id: \u00221\u0022) { score } }",
72-
"selectionSetId": 0
61+
"variable": "__fusion_exports__1"
7362
}
7463
]
7564
},
@@ -78,8 +67,31 @@
7867
"selectionSetIds": [
7968
0
8069
]
70+
},
71+
{
72+
"type": "Resolve",
73+
"subgraph": "Subgraph_2",
74+
"document": "query fetch_productById_2($__fusion_exports__1: ID!) { productById(id: $__fusion_exports__1) { score } }",
75+
"selectionSetId": 1,
76+
"path": [
77+
"productById"
78+
],
79+
"requires": [
80+
{
81+
"variable": "__fusion_exports__1"
82+
}
83+
]
84+
},
85+
{
86+
"type": "Compose",
87+
"selectionSetIds": [
88+
1
89+
]
8190
}
8291
]
92+
},
93+
"state": {
94+
"__fusion_exports__1": "Product_id"
8395
}
8496
}
8597
```

0 commit comments

Comments
 (0)