File tree Expand file tree Collapse file tree 5 files changed +34
-2
lines changed
src/test-suites/requires-with-argument Expand file tree Collapse file tree 5 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 1
1
# https://github.com/graphql-hive/gateway/releases
2
- curl -sSL https://graphql-hive.com/install-gateway.sh | sh -s " 1.14.2 "
2
+ curl -sSL https://graphql-hive.com/install-gateway.sh | sh -s " 1.15.0 "
Original file line number Diff line number Diff line change @@ -19,12 +19,23 @@ export default createSubgraph("a", {
19
19
price(currency: "USD") weight
20
20
"""
21
21
)
22
+ category: Category @external
23
+ isExpensiveCategory: Boolean
24
+ @requires(
25
+ fields: """
26
+ category { averagePrice(currency: "USD") }
27
+ """
28
+ )
29
+ }
30
+
31
+ type Category @external {
32
+ averagePrice(currency: String!): Int
22
33
}
23
34
` ,
24
35
resolvers : {
25
36
Product : {
26
37
__resolveReference (
27
- key : { upc : string ; price : number ; weight : number } | { upc : string } ,
38
+ key : { upc : string ; price : number ; weight : number } | { upc : string }
28
39
) {
29
40
const product = products . find ( ( p ) => p . upc === key . upc ) ;
30
41
@@ -37,16 +48,21 @@ export default createSubgraph("a", {
37
48
upc : product . upc ,
38
49
weight : key . weight ,
39
50
price : key . price ,
51
+ category : product . category ,
40
52
} ;
41
53
}
42
54
43
55
return {
44
56
upc : product . upc ,
57
+ category : product . category ,
45
58
} ;
46
59
} ,
47
60
shippingEstimate ( product : { price : number ; weight : number } ) {
48
61
return product . price * product . weight * 10 ;
49
62
} ,
63
+ isExpensiveCategory ( product : { category : { averagePrice : number } } ) {
64
+ return product . category . averagePrice > 11 ;
65
+ } ,
50
66
} ,
51
67
} ,
52
68
} ) ;
Original file line number Diff line number Diff line change @@ -15,6 +15,11 @@ export default createSubgraph("b", {
15
15
name: String
16
16
price(currency: String!): Int
17
17
weight: Int
18
+ category: Category
19
+ }
20
+
21
+ type Category {
22
+ averagePrice(currency: String!): Int
18
23
}
19
24
` ,
20
25
resolvers : {
@@ -25,6 +30,7 @@ export default createSubgraph("b", {
25
30
name : p . name ,
26
31
price : p . price ,
27
32
weight : p . weight ,
33
+ category : p . category ,
28
34
} ) ) ;
29
35
} ,
30
36
} ,
@@ -41,6 +47,7 @@ export default createSubgraph("b", {
41
47
name : product . name ,
42
48
price : product . price ,
43
49
weight : product . weight ,
50
+ category : product . category ,
44
51
} ;
45
52
} ,
46
53
} ,
Original file line number Diff line number Diff line change @@ -4,12 +4,18 @@ export const products = [
4
4
name : "p-name-1" ,
5
5
price : 11 ,
6
6
weight : 1 ,
7
+ category : {
8
+ averagePrice : 11 ,
9
+ } ,
7
10
} ,
8
11
{
9
12
upc : "p2" ,
10
13
name : "p-name-2" ,
11
14
price : 22 ,
12
15
weight : 2 ,
16
+ category : {
17
+ averagePrice : 22 ,
18
+ } ,
13
19
} ,
14
20
] ;
15
21
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ export default [
8
8
upc
9
9
name
10
10
shippingEstimate
11
+ isExpensiveCategory
11
12
}
12
13
}
13
14
` ,
@@ -18,11 +19,13 @@ export default [
18
19
upc : "p1" ,
19
20
name : "p-name-1" ,
20
21
shippingEstimate : 110 ,
22
+ isExpensiveCategory : false ,
21
23
} ,
22
24
{
23
25
upc : "p2" ,
24
26
name : "p-name-2" ,
25
27
shippingEstimate : 440 ,
28
+ isExpensiveCategory : true ,
26
29
} ,
27
30
] ,
28
31
} ,
You can’t perform that action at this time.
0 commit comments