@graphql-hive/federation-gateway-audit 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/.changeset/@graphql-hive_federation-gateway-audit-293-dependencies.md +5 -0
  2. package/.changeset/README.md +9 -0
  3. package/.changeset/config.json +18 -0
  4. package/.changeset/funky-times-cry.md +5 -0
  5. package/.github/CONTRIBUTING.md +9 -0
  6. package/.github/workflows/ci.yaml +97 -0
  7. package/.github/workflows/release.yml +58 -0
  8. package/LICENSE +21 -0
  9. package/README.md +113 -0
  10. package/REPORT.md +812 -0
  11. package/dist/cli.js +547 -0
  12. package/dist/env-Dj2M4ll3.cjs +15 -0
  13. package/dist/env-j1f_SZtG.js +13 -0
  14. package/dist/env-j1f_SZtG.mjs +13 -0
  15. package/dist/index--3rcSZqA.js +227 -0
  16. package/dist/index-0MDIXUzP.cjs +589 -0
  17. package/dist/index-19eD5lFk.mjs +163 -0
  18. package/dist/index-1ZtG04bN.js +222 -0
  19. package/dist/index-1nZTfbJn.cjs +168 -0
  20. package/dist/index-1smMXABT.mjs +227 -0
  21. package/dist/index-2oy7cA9A.js +225 -0
  22. package/dist/index-3BM15w2Y.mjs +234 -0
  23. package/dist/index-3CyAnc7j.js +234 -0
  24. package/dist/index-4Vj-ND7j.mjs +213 -0
  25. package/dist/index-4swHVe9x.cjs +507 -0
  26. package/dist/index-6itLA31k.js +382 -0
  27. package/dist/index-6qNpP2wc.mjs +238 -0
  28. package/dist/index-81CiuWlP.mjs +333 -0
  29. package/dist/index-8FxjbyOU.cjs +236 -0
  30. package/dist/index-A2YbwKzc.mjs +288 -0
  31. package/dist/index-B-YHHt9g.js +333 -0
  32. package/dist/index-B0coRevy.mjs +337 -0
  33. package/dist/index-B1NAc0TI.cjs +215 -0
  34. package/dist/index-B1WvIzTg.js +371 -0
  35. package/dist/index-B38OpRtf.js +166 -0
  36. package/dist/index-B3aDw4Tt.js +359 -0
  37. package/dist/index-B55AdoQy.js +273 -0
  38. package/dist/index-B7cr8XE-.js +194 -0
  39. package/dist/index-B7zN3YzE.cjs +683 -0
  40. package/dist/index-B8X923W3.mjs +262 -0
  41. package/dist/index-B958BFYC.cjs +224 -0
  42. package/dist/index-B9T896rB.mjs +163 -0
  43. package/dist/index-BA3ERnyq.mjs +234 -0
  44. package/dist/index-BDMi6sOm.cjs +252 -0
  45. package/dist/index-BDNWXFb_.mjs +304 -0
  46. package/dist/index-BEMScD_X.cjs +173 -0
  47. package/dist/index-BF0H5kP0.cjs +384 -0
  48. package/dist/index-BGC0_vWj.cjs +335 -0
  49. package/dist/index-BGNmWPAk.js +381 -0
  50. package/dist/index-BGUm947D.cjs +229 -0
  51. package/dist/index-BJB0tRA1.js +550 -0
  52. package/dist/index-BKcwbRZx.cjs +339 -0
  53. package/dist/index-BKpVb_h9.cjs +236 -0
  54. package/dist/index-BPFol6Ww.mjs +129 -0
  55. package/dist/index-BPza8i2Q.mjs +213 -0
  56. package/dist/index-BQQgQaGz.cjs +552 -0
  57. package/dist/index-BReFIfq_.cjs +361 -0
  58. package/dist/index-BS7JyQSU.js +250 -0
  59. package/dist/index-BSWSgZCO.cjs +252 -0
  60. package/dist/index-BStXx4OK.js +705 -0
  61. package/dist/index-BSwOAvti.js +288 -0
  62. package/dist/index-BWO8QbMB.mjs +587 -0
  63. package/dist/index-BYEdADrG.cjs +227 -0
  64. package/dist/index-B_eGT6oX.js +225 -0
  65. package/dist/index-B_u5Boud.js +333 -0
  66. package/dist/index-BaH3FI9i.cjs +361 -0
  67. package/dist/index-BaluTf1I.cjs +707 -0
  68. package/dist/index-BblYlZ3A.cjs +131 -0
  69. package/dist/index-BcZC0OIN.js +234 -0
  70. package/dist/index-Bcjyyjhh.mjs +259 -0
  71. package/dist/index-BcoW0aPo.cjs +165 -0
  72. package/dist/index-BdNZKlDU.js +284 -0
  73. package/dist/index-Bf81cAA1.mjs +444 -0
  74. package/dist/index-Bg3H3fgZ.js +259 -0
  75. package/dist/index-Bgl_1Y6Q.mjs +681 -0
  76. package/dist/index-BgmItHIB.mjs +129 -0
  77. package/dist/index-BgryMCqm.mjs +213 -0
  78. package/dist/index-Bh6a3eXK.mjs +227 -0
  79. package/dist/index-BhPDIfmU.js +304 -0
  80. package/dist/index-BiTzMTFn.js +304 -0
  81. package/dist/index-BjbmOyBP.cjs +215 -0
  82. package/dist/index-BjwZX2iS.mjs +273 -0
  83. package/dist/index-Bm8hqSRd.cjs +168 -0
  84. package/dist/index-BmOn6xYL.js +228 -0
  85. package/dist/index-BmQrhPXB.cjs +131 -0
  86. package/dist/index-Bnb8TpOO.js +280 -0
  87. package/dist/index-BndUB2KV.mjs +381 -0
  88. package/dist/index-Bo74nI4n.js +129 -0
  89. package/dist/index-BoGmP6Cy.cjs +230 -0
  90. package/dist/index-BodMjESw.mjs +250 -0
  91. package/dist/index-BpJZCoVH.mjs +250 -0
  92. package/dist/index-Br-Y1qC_.cjs +446 -0
  93. package/dist/index-BrFtcRgi.mjs +194 -0
  94. package/dist/index-BsPxDJAB.mjs +238 -0
  95. package/dist/index-Bu7pZnPO.cjs +170 -0
  96. package/dist/index-Bu8SXnTf.mjs +227 -0
  97. package/dist/index-BuNNRp3W.mjs +117 -0
  98. package/dist/index-Bwh8HVkw.cjs +384 -0
  99. package/dist/index-BxK3Y72_.js +227 -0
  100. package/dist/index-BxPUzymh.cjs +208 -0
  101. package/dist/index-ByUUB7Zn.js +250 -0
  102. package/dist/index-ByUr80PD.cjs +306 -0
  103. package/dist/index-ByZa9qm8.mjs +273 -0
  104. package/dist/index-BzPCjhuQ.cjs +264 -0
  105. package/dist/index-Bz_LTy1A.mjs +222 -0
  106. package/dist/index-C05_HMLC.js +225 -0
  107. package/dist/index-C15P-_1j.cjs +229 -0
  108. package/dist/index-C1GgHOiD.js +228 -0
  109. package/dist/index-C4Pk-zTm.mjs +227 -0
  110. package/dist/index-C4dnTlBf.js +262 -0
  111. package/dist/index-C6LW00iX.mjs +505 -0
  112. package/dist/index-C6nkQ480.js +225 -0
  113. package/dist/index-C8Mu4K9Q.cjs +383 -0
  114. package/dist/index-C8mB7yWC.mjs +288 -0
  115. package/dist/index-C9Eh7qBC.js +273 -0
  116. package/dist/index-CAJ9YPxc.js +681 -0
  117. package/dist/index-CD03pVUt.cjs +373 -0
  118. package/dist/index-CD8GiuIg.js +227 -0
  119. package/dist/index-CHB_0VqK.mjs +333 -0
  120. package/dist/index-CKEgb_R7.cjs +215 -0
  121. package/dist/index-CLsasg69.js +228 -0
  122. package/dist/index-CMdC_Cah.js +213 -0
  123. package/dist/index-CNOcqGKC.cjs +227 -0
  124. package/dist/index-CNvZCDZa.js +166 -0
  125. package/dist/index-CO0GiXGE.js +168 -0
  126. package/dist/index-COGhiFjk.mjs +284 -0
  127. package/dist/index-COIlelpZ.mjs +262 -0
  128. package/dist/index-CPph-RFN.mjs +168 -0
  129. package/dist/index-CPu_XkjY.mjs +304 -0
  130. package/dist/index-CQ5t4ZXm.js +117 -0
  131. package/dist/index-CQeQ1nto.js +681 -0
  132. package/dist/index-CSc_T8Lu.js +218 -0
  133. package/dist/index-CUFKuE64.js +550 -0
  134. package/dist/index-CW8h3l6M.js +262 -0
  135. package/dist/index-CWrng7Hd.mjs +550 -0
  136. package/dist/index-CWuObqnS.mjs +587 -0
  137. package/dist/index-CX7-wc6X.cjs +1837 -0
  138. package/dist/index-CXviN8qZ.cjs +224 -0
  139. package/dist/index-CY9mowWW.mjs +705 -0
  140. package/dist/index-C_pTgB_1.js +194 -0
  141. package/dist/index-C_qaNb-X.mjs +225 -0
  142. package/dist/index-Ca0FeU7u.js +505 -0
  143. package/dist/index-Cb3ImEjd.cjs +165 -0
  144. package/dist/index-Cbhvi8yk.cjs +229 -0
  145. package/dist/index-Cc3vrs6_.mjs +228 -0
  146. package/dist/index-CcIXvx40.mjs +171 -0
  147. package/dist/index-CdaeeF3f.cjs +306 -0
  148. package/dist/index-CddVoIp2.js +213 -0
  149. package/dist/index-CeiRxGcN.mjs +218 -0
  150. package/dist/index-ChefKWWr.mjs +381 -0
  151. package/dist/index-Cj2ocjXI.cjs +227 -0
  152. package/dist/index-CkWEXzTN.js +129 -0
  153. package/dist/index-Ckhb9QAu.cjs +264 -0
  154. package/dist/index-CklJfQlf.cjs +220 -0
  155. package/dist/index-Cmh7PJUd.mjs +372 -0
  156. package/dist/index-Cn0ZJkAv.mjs +280 -0
  157. package/dist/index-CqTzarV1.mjs +198 -0
  158. package/dist/index-CrUbbFxE.js +284 -0
  159. package/dist/index-CsKaFB2K.mjs +228 -0
  160. package/dist/index-Cu8Ii5r7.cjs +335 -0
  161. package/dist/index-Cuw9ylL-.mjs +371 -0
  162. package/dist/index-CwOULUAt.mjs +382 -0
  163. package/dist/index-CyVnRqjE.cjs +196 -0
  164. package/dist/index-D-1dDKiZ.mjs +227 -0
  165. package/dist/index-D00bnaJy.cjs +220 -0
  166. package/dist/index-D07xiOJ6.cjs +446 -0
  167. package/dist/index-D1Ip6ro6.js +458 -0
  168. package/dist/index-D1Ymvd2b.cjs +286 -0
  169. package/dist/index-D5jOBT3f.cjs +240 -0
  170. package/dist/index-D5tEp8IU.js +337 -0
  171. package/dist/index-D7WuGKYY.cjs +227 -0
  172. package/dist/index-D8Dp6TnQ.cjs +1837 -0
  173. package/dist/index-D9OKpqgG.js +381 -0
  174. package/dist/index-DBMI2EcB.cjs +170 -0
  175. package/dist/index-DBRUKV0U.mjs +225 -0
  176. package/dist/index-DEvExC5x.cjs +119 -0
  177. package/dist/index-DEzxU_gQ.cjs +507 -0
  178. package/dist/index-DFypMD6R.cjs +261 -0
  179. package/dist/index-DHRqE92a.cjs +290 -0
  180. package/dist/index-DISym5OL.js +198 -0
  181. package/dist/index-DJ3ndv3i.mjs +705 -0
  182. package/dist/index-DJXP-Gmp.js +218 -0
  183. package/dist/index-DJlXDQOY.cjs +200 -0
  184. package/dist/index-DLW4GEJl.cjs +229 -0
  185. package/dist/index-DLu9E2Vq.js +238 -0
  186. package/dist/index-DM4ddIL6.js +382 -0
  187. package/dist/index-DMgHLbwU.cjs +339 -0
  188. package/dist/index-DN-ScBql.mjs +458 -0
  189. package/dist/index-DOkkIHER.js +163 -0
  190. package/dist/index-DRY8sDun.cjs +165 -0
  191. package/dist/index-DS3cjugP.mjs +171 -0
  192. package/dist/index-DS86eFsI.mjs +1835 -0
  193. package/dist/index-DUlT8CJ2.js +458 -0
  194. package/dist/index-DV1F4nxP.js +372 -0
  195. package/dist/index-DXsAcJ-o.mjs +359 -0
  196. package/dist/index-DZws2w4w.cjs +229 -0
  197. package/dist/index-D_HiVe2_.cjs +200 -0
  198. package/dist/index-Da6L5V_Z.mjs +681 -0
  199. package/dist/index-Dbb-jnWf.js +206 -0
  200. package/dist/index-DdXy_-T9.js +444 -0
  201. package/dist/index-DddNFRG3.js +337 -0
  202. package/dist/index-DejhKwvw.cjs +173 -0
  203. package/dist/index-DfBdD-5Z.cjs +383 -0
  204. package/dist/index-Df_KCbC4.mjs +213 -0
  205. package/dist/index-DiDq1sL6.cjs +240 -0
  206. package/dist/index-DiuJQ9Mq.js +198 -0
  207. package/dist/index-Djqj3DWJ.js +171 -0
  208. package/dist/index-Dk0q-ENv.mjs +166 -0
  209. package/dist/index-DlFElztE.mjs +163 -0
  210. package/dist/index-DlkxQ-B5.mjs +359 -0
  211. package/dist/index-Dm5kpK9t.js +227 -0
  212. package/dist/index-Dp8mobro.js +444 -0
  213. package/dist/index-DpBWZa1x.cjs +683 -0
  214. package/dist/index-DrkXuLUZ.js +227 -0
  215. package/dist/index-Dsq1FK90.cjs +275 -0
  216. package/dist/index-DtmhGgM8.cjs +282 -0
  217. package/dist/index-Du5MxO_2.mjs +505 -0
  218. package/dist/index-DveYQLCZ.cjs +460 -0
  219. package/dist/index-DxHMqS-W.js +117 -0
  220. package/dist/index-DyTApTHI.cjs +282 -0
  221. package/dist/index-DyTSkAm4.cjs +208 -0
  222. package/dist/index-DygJOEne.mjs +550 -0
  223. package/dist/index-DzAewrkw.js +238 -0
  224. package/dist/index-ESWdD7ek.cjs +215 -0
  225. package/dist/index-EuKHpnHv.mjs +117 -0
  226. package/dist/index-F1A7LMlw.mjs +228 -0
  227. package/dist/index-FP6hvgSw.cjs +552 -0
  228. package/dist/index-GDSrKnPp.mjs +198 -0
  229. package/dist/index-GMCZo-KH.js +222 -0
  230. package/dist/index-IQJLr7nR.js +288 -0
  231. package/dist/index-IawHHRZX.mjs +206 -0
  232. package/dist/index-Jk7MG7tE.cjs +286 -0
  233. package/dist/index-JtGxTXPr.mjs +337 -0
  234. package/dist/index-KAC20a9r.js +359 -0
  235. package/dist/index-LVWQqV-v.js +163 -0
  236. package/dist/index-Ls2fI7y4.js +163 -0
  237. package/dist/index-NB1VDvjW.cjs +374 -0
  238. package/dist/index-NIEZaRYg.cjs +261 -0
  239. package/dist/index-PQXUx1ZR.mjs +1835 -0
  240. package/dist/index-PyaLRKuk.mjs +168 -0
  241. package/dist/index-QQGo-BV1.mjs +444 -0
  242. package/dist/index-QXYDkAsQ.cjs +119 -0
  243. package/dist/index-SmEIf5jz.mjs +259 -0
  244. package/dist/index-UJhFwnD_.mjs +284 -0
  245. package/dist/index-UVyXzNlG.js +705 -0
  246. package/dist/index-UgyHGpUU.mjs +163 -0
  247. package/dist/index-UhQiJabs.cjs +707 -0
  248. package/dist/index-VvuhRvnC.mjs +218 -0
  249. package/dist/index-WPXuueaq.mjs +194 -0
  250. package/dist/index-X4u6bs58.js +259 -0
  251. package/dist/index-XZiO6uje.cjs +275 -0
  252. package/dist/index-YOlsBREZ.cjs +230 -0
  253. package/dist/index-Ytb942t9.js +587 -0
  254. package/dist/index-_2dg_MWu.cjs +460 -0
  255. package/dist/index-eFEW10em.js +213 -0
  256. package/dist/index-eq8bbEej.mjs +225 -0
  257. package/dist/index-f7FiDQMk.js +171 -0
  258. package/dist/index-fBzI1kbw.mjs +225 -0
  259. package/dist/index-fdDnq3vQ.js +163 -0
  260. package/dist/index-fqmAgjhG.js +206 -0
  261. package/dist/index-ikGyewP-.cjs +165 -0
  262. package/dist/index-jft-1bQ6.cjs +230 -0
  263. package/dist/index-l8e8ip4U.js +168 -0
  264. package/dist/index-lkBiml03.js +1835 -0
  265. package/dist/index-mm-YMeoi.js +505 -0
  266. package/dist/index-o7g3iua7.cjs +290 -0
  267. package/dist/index-ojnncNWd.js +587 -0
  268. package/dist/index-q9SCjCJM.mjs +280 -0
  269. package/dist/index-rn-_7-wp.cjs +196 -0
  270. package/dist/index-s27DHpTG.js +1835 -0
  271. package/dist/index-s2HuXM4d.mjs +206 -0
  272. package/dist/index-sbc7nDv3.js +213 -0
  273. package/dist/index-tx0X6vuE.mjs +222 -0
  274. package/dist/index-uCwv2hr-.mjs +166 -0
  275. package/dist/index-vHngHSlz.js +280 -0
  276. package/dist/index-xOtG5E4u.cjs +589 -0
  277. package/dist/index-zJk-Nm6b.mjs +458 -0
  278. package/dist/index-zqxgDrLR.mjs +382 -0
  279. package/dist/index.cjs +233 -0
  280. package/dist/index.d.cts +9 -0
  281. package/dist/index.d.cts.map +1 -0
  282. package/dist/index.d.ts +9 -0
  283. package/dist/index.d.ts.map +1 -0
  284. package/dist/index.js +230 -0
  285. package/dist/index.mjs +230 -0
  286. package/dist/testkit-BtZjdl4n.js +269 -0
  287. package/dist/testkit-BtZjdl4n.mjs +269 -0
  288. package/dist/testkit-C920qivh.js +281 -0
  289. package/dist/testkit-C920qivh.mjs +281 -0
  290. package/dist/testkit-CAf-AsDy.cjs +273 -0
  291. package/dist/testkit-D0rTQ6MD.cjs +286 -0
  292. package/makefile +47 -0
  293. package/package.json +89 -0
@@ -0,0 +1,1837 @@
1
+ 'use strict';
2
+
3
+ var testkit = require('./testkit-CAf-AsDy.cjs');
4
+ require('@apollo/composition');
5
+ require('graphql');
6
+ require('fets');
7
+ require('@apollo/subgraph');
8
+ require('graphql-yoga');
9
+
10
+ const users = [
11
+ {
12
+ id: "u1",
13
+ email: "u1@example.com",
14
+ name: "u1-name"
15
+ },
16
+ {
17
+ id: "u2",
18
+ email: "u2@example.com",
19
+ name: "u2-name"
20
+ },
21
+ {
22
+ id: "u3",
23
+ email: "u3@example.com",
24
+ name: "u3-name"
25
+ }
26
+ ];
27
+ const books = [
28
+ {
29
+ __typename: "Book",
30
+ id: "p1",
31
+ sku: "sku-1",
32
+ title: "Book 1",
33
+ createdBy: "u1",
34
+ dimensions: {
35
+ size: "small",
36
+ weight: 0.5
37
+ },
38
+ publisher: {
39
+ __typename: "Self",
40
+ email: users[0].email
41
+ },
42
+ hidden: false
43
+ },
44
+ {
45
+ __typename: "Book",
46
+ id: "p3",
47
+ sku: "sku-3",
48
+ title: "Book 2",
49
+ createdBy: "u2",
50
+ dimensions: {
51
+ size: "small",
52
+ weight: 0.6
53
+ },
54
+ publisher: {
55
+ __typename: "Agency",
56
+ id: "a1"
57
+ },
58
+ hidden: false
59
+ }
60
+ ];
61
+ const magazines = [
62
+ {
63
+ __typename: "Magazine",
64
+ id: "p2",
65
+ sku: "sku-2",
66
+ title: "Magazine 1",
67
+ createdBy: "u1",
68
+ dimensions: {
69
+ size: "small",
70
+ weight: 0.2
71
+ },
72
+ publisher: {
73
+ __typename: "Agency",
74
+ id: "a1"
75
+ },
76
+ hidden: false
77
+ },
78
+ {
79
+ __typename: "Magazine",
80
+ id: "p4",
81
+ sku: "sku-4",
82
+ title: "Magazine 2",
83
+ createdBy: "u2",
84
+ dimensions: {
85
+ size: "small",
86
+ weight: 0.3
87
+ },
88
+ publisher: {
89
+ __typename: "Self",
90
+ email: users[0].email
91
+ },
92
+ hidden: true
93
+ }
94
+ ];
95
+ const products = [...books, ...magazines];
96
+ const reviews = [
97
+ {
98
+ id: 1,
99
+ body: "review 1",
100
+ productId: "p1",
101
+ score: 3
102
+ },
103
+ {
104
+ id: 2,
105
+ body: "review 2",
106
+ productId: "p1",
107
+ score: 4
108
+ },
109
+ {
110
+ id: 3,
111
+ body: "review 3",
112
+ productId: "p2",
113
+ score: 5
114
+ }
115
+ ];
116
+ const agencies = [
117
+ {
118
+ id: "a1",
119
+ companyName: "Agency 1",
120
+ email: {
121
+ address: "a1@example.com"
122
+ }
123
+ }
124
+ ];
125
+
126
+ var inventorySubgraph = testkit.createSubgraph("inventory", {
127
+ typeDefs: (
128
+ /* GraphQL */
129
+ `
130
+ extend schema
131
+ @link(
132
+ url: "https://specs.apollo.dev/federation/v2.3"
133
+ import: ["@key", "@shareable", "@external", "@requires"]
134
+ )
135
+
136
+ interface Product {
137
+ id: ID!
138
+ dimensions: ProductDimension
139
+ delivery(zip: String): DeliveryEstimates
140
+ }
141
+
142
+ type Book implements Product @key(fields: "id") {
143
+ id: ID!
144
+ dimensions: ProductDimension @external
145
+ delivery(zip: String): DeliveryEstimates
146
+ @requires(fields: "dimensions { size weight }")
147
+ }
148
+
149
+ type Magazine implements Product @key(fields: "id") {
150
+ id: ID!
151
+ dimensions: ProductDimension @external
152
+ delivery(zip: String): DeliveryEstimates
153
+ @requires(fields: "dimensions { size weight }")
154
+ }
155
+
156
+ type ProductDimension @shareable {
157
+ size: String
158
+ weight: Float
159
+ }
160
+
161
+ type DeliveryEstimates {
162
+ estimatedDelivery: String
163
+ fastestDelivery: String
164
+ }
165
+ `
166
+ ),
167
+ resolvers: {
168
+ Book: {
169
+ __resolveReference(key) {
170
+ const book = books.find((book2) => book2.id === key.id);
171
+ if (!book) {
172
+ return null;
173
+ }
174
+ return {
175
+ __typename: book.__typename,
176
+ id: book.id,
177
+ dimensions: key.dimensions
178
+ };
179
+ },
180
+ delivery({ dimensions }, { zip }) {
181
+ if (!zip) {
182
+ return null;
183
+ }
184
+ if (!dimensions) {
185
+ return null;
186
+ }
187
+ if (dimensions.size === "small" && dimensions.weight < 1) {
188
+ return {
189
+ estimatedDelivery: "1 day",
190
+ fastestDelivery: "same day"
191
+ };
192
+ }
193
+ if (dimensions.size === "large" && dimensions.weight >= 1) {
194
+ return {
195
+ estimatedDelivery: "3 days",
196
+ fastestDelivery: "2 days"
197
+ };
198
+ }
199
+ return null;
200
+ }
201
+ },
202
+ Magazine: {
203
+ __resolveReference(key) {
204
+ const magazine = magazines.find((magazine2) => magazine2.id === key.id);
205
+ if (!magazine) {
206
+ return null;
207
+ }
208
+ return {
209
+ __typename: magazine.__typename,
210
+ id: magazine.id,
211
+ dimensions: key.dimensions
212
+ };
213
+ },
214
+ delivery({ dimensions }, { zip }) {
215
+ if (!zip) {
216
+ return null;
217
+ }
218
+ if (!dimensions) {
219
+ return null;
220
+ }
221
+ if (dimensions.size === "small" && dimensions.weight < 1) {
222
+ return {
223
+ estimatedDelivery: "1 day",
224
+ fastestDelivery: "same day"
225
+ };
226
+ }
227
+ if (dimensions.size === "large" && dimensions.weight >= 1) {
228
+ return {
229
+ estimatedDelivery: "3 days",
230
+ fastestDelivery: "2 days"
231
+ };
232
+ }
233
+ return null;
234
+ }
235
+ }
236
+ }
237
+ });
238
+
239
+ var booksSubgraph = testkit.createSubgraph("books", {
240
+ typeDefs: (
241
+ /* GraphQL */
242
+ `
243
+ schema
244
+ @link(
245
+ url: "https://specs.apollo.dev/federation/v2.3"
246
+ import: ["@key", "@shareable", "@external", "@requires"]
247
+ ) {
248
+ query: Query
249
+ }
250
+
251
+ type Book @key(fields: "id") {
252
+ id: ID!
253
+ title: String
254
+ }
255
+
256
+ type Query {
257
+ books: [Book]
258
+ }
259
+ `
260
+ ),
261
+ resolvers: {
262
+ Query: {
263
+ books() {
264
+ return books.map((book) => ({
265
+ __typename: "Book",
266
+ id: book.id,
267
+ title: book.title
268
+ }));
269
+ }
270
+ },
271
+ Book: {
272
+ __resolveReference(key) {
273
+ const book = books.find((book2) => book2.id === key.id);
274
+ return book ? {
275
+ __typename: "Book",
276
+ id: book.id,
277
+ title: book.title
278
+ } : null;
279
+ }
280
+ }
281
+ }
282
+ });
283
+
284
+ var usersSubgraph = testkit.createSubgraph("users", {
285
+ typeDefs: (
286
+ /* GraphQL */
287
+ `
288
+ type User @key(fields: "email") {
289
+ email: ID!
290
+ name: String
291
+ totalProductsCreated: Int
292
+ }
293
+ `
294
+ ),
295
+ resolvers: {
296
+ User: {
297
+ __resolveReference(key) {
298
+ const user = users.find((user2) => user2.email === key.email);
299
+ return user ? {
300
+ __typename: "User",
301
+ id: user.id,
302
+ email: user.email,
303
+ name: user.name
304
+ } : null;
305
+ },
306
+ totalProductsCreated(user) {
307
+ return products.filter((p) => p.createdBy === user.id).length;
308
+ }
309
+ }
310
+ }
311
+ });
312
+
313
+ var productsSubgraph = testkit.createSubgraph("products", {
314
+ typeDefs: (
315
+ /* GraphQL */
316
+ `
317
+ schema
318
+ @link(
319
+ url: "https://specs.apollo.dev/federation/v2.3"
320
+ import: ["@key", "@shareable", "@inaccessible", "@external"]
321
+ ) {
322
+ query: Query
323
+ }
324
+
325
+ type Query {
326
+ products: [Product]
327
+ similar(id: ID!): [Product]
328
+ }
329
+
330
+ interface Product {
331
+ id: ID!
332
+ sku: String
333
+ dimensions: ProductDimension
334
+ createdBy: User
335
+ hidden: Boolean @inaccessible
336
+ }
337
+
338
+ interface Similar {
339
+ similar: [Product]
340
+ }
341
+
342
+ type ProductDimension @shareable {
343
+ size: String
344
+ weight: Float
345
+ }
346
+
347
+ type Book implements Product & Similar @key(fields: "id") {
348
+ id: ID!
349
+ sku: String
350
+ dimensions: ProductDimension @shareable
351
+ createdBy: User
352
+ similar: [Book]
353
+ hidden: Boolean
354
+ publisherType: PublisherType
355
+ }
356
+
357
+ type Magazine implements Product & Similar @key(fields: "id") {
358
+ id: ID!
359
+ sku: String
360
+ dimensions: ProductDimension @shareable
361
+ createdBy: User
362
+ similar: [Magazine]
363
+ hidden: Boolean
364
+ publisherType: PublisherType
365
+ }
366
+
367
+ union PublisherType = Agency | Self
368
+
369
+ type Agency {
370
+ id: ID! @shareable
371
+ }
372
+
373
+ type Self {
374
+ email: String
375
+ }
376
+
377
+ type User @key(fields: "email") {
378
+ email: ID!
379
+ totalProductsCreated: Int @shareable
380
+ }
381
+ `
382
+ ),
383
+ resolvers: {
384
+ Query: {
385
+ products() {
386
+ return products.map((p) => ({
387
+ __typename: p.__typename,
388
+ id: p.id,
389
+ sku: p.sku,
390
+ dimensions: p.dimensions,
391
+ createdBy: p.createdBy,
392
+ hidden: p.hidden,
393
+ publisherType: p.publisher
394
+ }));
395
+ },
396
+ similar(_, { id }) {
397
+ const product = products.find((product2) => product2.id === id);
398
+ if (!product) {
399
+ return [];
400
+ }
401
+ const similar = products.filter(
402
+ (p) => p.id !== product.id && p.__typename === product.__typename
403
+ );
404
+ return similar.map((b) => ({
405
+ __typename: b.__typename,
406
+ id: b.id,
407
+ sku: b.sku,
408
+ dimensions: b.dimensions,
409
+ createdBy: b.createdBy,
410
+ hidden: b.hidden,
411
+ publisherType: b.publisher
412
+ }));
413
+ }
414
+ },
415
+ Book: {
416
+ __resolveReference(key) {
417
+ const book = books.find((book2) => book2.id === key.id);
418
+ return book ? {
419
+ __typename: book.__typename,
420
+ id: book.id,
421
+ sku: book.sku,
422
+ dimensions: book.dimensions,
423
+ createdBy: book.createdBy,
424
+ hidden: book.hidden,
425
+ publisherType: book.publisher
426
+ } : null;
427
+ },
428
+ similar(book) {
429
+ return books.filter((b) => b.id !== book.id).map((b) => ({
430
+ __typename: b.__typename,
431
+ id: b.id,
432
+ sku: b.sku,
433
+ dimensions: b.dimensions,
434
+ createdBy: b.createdBy,
435
+ hidden: b.hidden,
436
+ publisherType: b.publisher
437
+ }));
438
+ },
439
+ createdBy(book) {
440
+ const user = users.find((user2) => user2.id === book.createdBy);
441
+ return user ? {
442
+ __typename: "User",
443
+ id: user.id,
444
+ email: user.email
445
+ } : null;
446
+ }
447
+ },
448
+ Magazine: {
449
+ __resolveReference(key) {
450
+ const magazine = magazines.find((magazine2) => magazine2.id === key.id);
451
+ return magazine ? {
452
+ __typename: magazine.__typename,
453
+ id: magazine.id,
454
+ sku: magazine.sku,
455
+ dimensions: magazine.dimensions,
456
+ createdBy: magazine.createdBy,
457
+ hidden: magazine.hidden,
458
+ publisherType: magazine.publisher
459
+ } : null;
460
+ },
461
+ similar(magazine) {
462
+ return magazines.filter((m) => m.id !== magazine.id).map((m) => ({
463
+ __typename: m.__typename,
464
+ id: m.id,
465
+ sku: m.sku,
466
+ dimensions: m.dimensions,
467
+ createdBy: m.createdBy,
468
+ hidden: m.hidden,
469
+ publisherType: m.publisher
470
+ }));
471
+ },
472
+ createdBy(magazine) {
473
+ const user = users.find((user2) => user2.id === magazine.createdBy);
474
+ return user ? {
475
+ __typename: "User",
476
+ id: user.id,
477
+ email: user.email
478
+ } : null;
479
+ }
480
+ },
481
+ User: {
482
+ __resolveReference(key) {
483
+ const user = users.find((user2) => user2.email === key.email);
484
+ return user ? {
485
+ __typename: "User",
486
+ id: user.id,
487
+ email: user.email
488
+ } : null;
489
+ },
490
+ totalProductsCreated(user) {
491
+ return products.filter((product) => product.createdBy === user.id).length;
492
+ }
493
+ }
494
+ }
495
+ });
496
+
497
+ const Product = {
498
+ __resolveReference(key) {
499
+ const product = products.find((product2) => product2.id === key.id);
500
+ return product ? {
501
+ __typename: product.__typename,
502
+ id: product.id,
503
+ similar: key.similar
504
+ } : null;
505
+ },
506
+ reviews(product) {
507
+ return reviews.filter((review) => review.productId === product.id).map((review) => {
508
+ const product2 = products.find(
509
+ (product3) => product3.id === review.productId
510
+ );
511
+ return {
512
+ __typename: "Review",
513
+ id: review.id,
514
+ body: review.body,
515
+ product: product2 ? {
516
+ __typename: product2.__typename,
517
+ id: product2.id
518
+ } : null
519
+ };
520
+ });
521
+ },
522
+ reviewsCount(product) {
523
+ return reviews.filter((review) => review.productId === product.id).length;
524
+ },
525
+ reviewsScore(product) {
526
+ const productReviews = reviews.filter(
527
+ (review) => review.productId === product.id
528
+ );
529
+ if (productReviews.length === 0) {
530
+ return 0;
531
+ }
532
+ const sum = productReviews.reduce((acc, review) => acc + review.score, 0);
533
+ return sum / productReviews.length;
534
+ },
535
+ reviewsOfSimilar(product) {
536
+ const similarProducts = products.filter(
537
+ (p) => p.__typename === product.__typename && product.similar.id.includes(p.id)
538
+ );
539
+ return similarProducts.flatMap((p) => reviews.filter((review) => review.productId === p.id)).map((review) => {
540
+ const product2 = products.find(
541
+ (product3) => product3.id === review.productId
542
+ );
543
+ return {
544
+ __typename: "Review",
545
+ id: review.id,
546
+ body: review.body,
547
+ product: product2 ? {
548
+ __typename: product2.__typename,
549
+ id: product2.id
550
+ } : null
551
+ };
552
+ });
553
+ }
554
+ };
555
+ var reviewsSubgraph = testkit.createSubgraph("reviews", {
556
+ typeDefs: (
557
+ /* GraphQL */
558
+ `
559
+ schema
560
+ @link(
561
+ url: "https://specs.apollo.dev/federation/v2.3"
562
+ import: ["@key", "@shareable", "@requires", "@external"]
563
+ ) {
564
+ query: Query
565
+ }
566
+
567
+ type Book implements Product & Similar @key(fields: "id") {
568
+ id: ID!
569
+ reviewsCount: Int!
570
+ reviewsScore: Float! @shareable
571
+ reviews: [Review!]!
572
+ similar: [Book] @external
573
+ reviewsOfSimilar: [Review!]! @requires(fields: "similar { id }")
574
+ }
575
+
576
+ type Magazine implements Product & Similar @key(fields: "id") {
577
+ id: ID!
578
+ reviewsCount: Int!
579
+ reviewsScore: Float! @shareable
580
+ reviews: [Review!]!
581
+ similar: [Magazine] @external
582
+ reviewsOfSimilar: [Review!]! @requires(fields: "similar { id }")
583
+ }
584
+
585
+ interface Product {
586
+ id: ID!
587
+ reviewsCount: Int!
588
+ reviewsScore: Float!
589
+ reviews: [Review!]!
590
+ }
591
+
592
+ interface Similar {
593
+ similar: [Product]
594
+ }
595
+
596
+ type Query {
597
+ review(id: Int!): Review
598
+ }
599
+
600
+ type Review {
601
+ id: Int!
602
+ body: String!
603
+ product: Product
604
+ }
605
+ `
606
+ ),
607
+ resolvers: {
608
+ Query: {
609
+ review(_, { id }) {
610
+ const review = reviews.find((review2) => review2.id === id);
611
+ if (!review) {
612
+ return null;
613
+ }
614
+ const product = products.find(
615
+ (product2) => product2.id === review.productId
616
+ );
617
+ return {
618
+ __typename: "Review",
619
+ id: review.id,
620
+ body: review.body,
621
+ product: product ? {
622
+ __typename: product.__typename,
623
+ id: product.id
624
+ } : null
625
+ };
626
+ }
627
+ },
628
+ Book: Product,
629
+ Magazine: Product
630
+ }
631
+ });
632
+
633
+ var magazinesSubgraph = testkit.createSubgraph("magazines", {
634
+ typeDefs: (
635
+ /* GraphQL */
636
+ `
637
+ schema
638
+ @link(
639
+ url: "https://specs.apollo.dev/federation/v2.3"
640
+ import: ["@key", "@shareable"]
641
+ ) {
642
+ query: Query
643
+ }
644
+
645
+ type Magazine @key(fields: "id") {
646
+ id: ID!
647
+ title: String
648
+ }
649
+
650
+ type Query {
651
+ magazines: [Magazine]
652
+ }
653
+ `
654
+ ),
655
+ resolvers: {
656
+ Query: {
657
+ magazines() {
658
+ return magazines.map((magazine) => ({
659
+ __typename: magazine.__typename,
660
+ id: magazine.id,
661
+ title: magazine.title
662
+ }));
663
+ }
664
+ },
665
+ Magazine: {
666
+ __resolveReference(key) {
667
+ const magazine = magazines.find((magazine2) => magazine2.id === key.id);
668
+ return magazine ? {
669
+ __typename: magazine.__typename,
670
+ id: magazine.id,
671
+ title: magazine.title
672
+ } : null;
673
+ }
674
+ }
675
+ }
676
+ });
677
+
678
+ var agencySubgraph = testkit.createSubgraph("agency", {
679
+ typeDefs: (
680
+ /* GraphQL */
681
+ `
682
+ extend schema
683
+ @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key"])
684
+
685
+ type Agency @key(fields: "id") {
686
+ id: ID!
687
+ companyName: String
688
+ email: Email
689
+ }
690
+
691
+ type Email {
692
+ address: String
693
+ }
694
+
695
+ type Group @key(fields: "id") {
696
+ id: ID!
697
+ name: String
698
+ email: String
699
+ }
700
+
701
+ extend union PublisherType = Agency | Group
702
+ `
703
+ ),
704
+ resolvers: {
705
+ Agency: {
706
+ __resolveReference(key) {
707
+ return agencies.find((a) => a.id === key.id);
708
+ }
709
+ },
710
+ Group: {
711
+ __resolveReference(key) {
712
+ return {
713
+ id: key.id,
714
+ name: "Group " + key.id,
715
+ email: "group" + key.id + "@example.com"
716
+ };
717
+ }
718
+ }
719
+ }
720
+ });
721
+
722
+ var test = [
723
+ testkit.createTest(
724
+ /* GraphQL */
725
+ `
726
+ query {
727
+ products {
728
+ id
729
+ dimensions {
730
+ size
731
+ weight
732
+ }
733
+ }
734
+ }
735
+ `,
736
+ {
737
+ data: {
738
+ products: [
739
+ {
740
+ id: "p1",
741
+ dimensions: {
742
+ size: "small",
743
+ weight: 0.5
744
+ }
745
+ },
746
+ {
747
+ id: "p3",
748
+ dimensions: {
749
+ size: "small",
750
+ weight: 0.6
751
+ }
752
+ },
753
+ {
754
+ id: "p2",
755
+ dimensions: {
756
+ size: "small",
757
+ weight: 0.2
758
+ }
759
+ },
760
+ {
761
+ id: "p4",
762
+ dimensions: {
763
+ size: "small",
764
+ weight: 0.3
765
+ }
766
+ }
767
+ ]
768
+ }
769
+ }
770
+ ),
771
+ testkit.createTest(
772
+ /* GraphQL */
773
+ `
774
+ query {
775
+ similar(id: "p1") {
776
+ id
777
+ sku
778
+ }
779
+ }
780
+ `,
781
+ {
782
+ data: {
783
+ similar: [
784
+ {
785
+ id: "p3",
786
+ sku: "sku-3"
787
+ }
788
+ ]
789
+ }
790
+ }
791
+ ),
792
+ testkit.createTest(
793
+ /* GraphQL */
794
+ `
795
+ query {
796
+ book: similar(id: "p1") {
797
+ id
798
+ sku
799
+ delivery(zip: "1234") {
800
+ fastestDelivery
801
+ estimatedDelivery
802
+ }
803
+ }
804
+ magazine: similar(id: "p2") {
805
+ id
806
+ sku
807
+ delivery(zip: "1234") {
808
+ fastestDelivery
809
+ estimatedDelivery
810
+ }
811
+ }
812
+ }
813
+ `,
814
+ {
815
+ data: {
816
+ book: [
817
+ {
818
+ id: "p3",
819
+ sku: "sku-3",
820
+ delivery: {
821
+ fastestDelivery: "same day",
822
+ estimatedDelivery: "1 day"
823
+ }
824
+ }
825
+ ],
826
+ magazine: [
827
+ {
828
+ id: "p4",
829
+ sku: "sku-4",
830
+ delivery: {
831
+ fastestDelivery: "same day",
832
+ estimatedDelivery: "1 day"
833
+ }
834
+ }
835
+ ]
836
+ }
837
+ }
838
+ ),
839
+ testkit.createTest(
840
+ /* GraphQL */
841
+ `
842
+ {
843
+ products {
844
+ sku
845
+ ... on Product {
846
+ sku
847
+ }
848
+ ... on Book {
849
+ sku
850
+ }
851
+ ... on Magazine {
852
+ sku
853
+ }
854
+ ... on Similar {
855
+ __typename
856
+ type: __typename
857
+ }
858
+ }
859
+ }
860
+ `,
861
+ {
862
+ data: {
863
+ products: [
864
+ {
865
+ sku: "sku-1",
866
+ __typename: "Book",
867
+ type: "Book"
868
+ },
869
+ {
870
+ sku: "sku-3",
871
+ __typename: "Book",
872
+ type: "Book"
873
+ },
874
+ {
875
+ sku: "sku-2",
876
+ __typename: "Magazine",
877
+ type: "Magazine"
878
+ },
879
+ {
880
+ sku: "sku-4",
881
+ __typename: "Magazine",
882
+ type: "Magazine"
883
+ }
884
+ ]
885
+ }
886
+ }
887
+ ),
888
+ testkit.createTest(
889
+ /* GraphQL */
890
+ `
891
+ {
892
+ products {
893
+ author: createdBy {
894
+ email
895
+ totalProductsCreated
896
+ }
897
+ ... on Magazine {
898
+ title
899
+ }
900
+ }
901
+ }
902
+ `,
903
+ {
904
+ data: {
905
+ products: [
906
+ {
907
+ author: {
908
+ email: "u1@example.com",
909
+ totalProductsCreated: 2
910
+ }
911
+ },
912
+ {
913
+ author: {
914
+ email: "u2@example.com",
915
+ totalProductsCreated: 2
916
+ }
917
+ },
918
+ {
919
+ author: {
920
+ email: "u1@example.com",
921
+ totalProductsCreated: 2
922
+ },
923
+ title: "Magazine 1"
924
+ },
925
+ {
926
+ author: {
927
+ email: "u2@example.com",
928
+ totalProductsCreated: 2
929
+ },
930
+ title: "Magazine 2"
931
+ }
932
+ ]
933
+ }
934
+ }
935
+ ),
936
+ testkit.createTest(
937
+ /* GraphQL */
938
+ `
939
+ {
940
+ products {
941
+ id
942
+ reviews {
943
+ product {
944
+ sku
945
+ ... on Magazine {
946
+ title
947
+ }
948
+ ... on Book {
949
+ reviewsCount
950
+ }
951
+ }
952
+ }
953
+ }
954
+ }
955
+ `,
956
+ {
957
+ data: {
958
+ products: [
959
+ {
960
+ id: "p1",
961
+ reviews: [
962
+ {
963
+ product: {
964
+ sku: "sku-1",
965
+ reviewsCount: 2
966
+ }
967
+ },
968
+ {
969
+ product: {
970
+ sku: "sku-1",
971
+ reviewsCount: 2
972
+ }
973
+ }
974
+ ]
975
+ },
976
+ {
977
+ id: "p3",
978
+ reviews: []
979
+ },
980
+ {
981
+ id: "p2",
982
+ reviews: [
983
+ {
984
+ product: {
985
+ sku: "sku-2",
986
+ title: "Magazine 1"
987
+ }
988
+ }
989
+ ]
990
+ },
991
+ {
992
+ id: "p4",
993
+ reviews: []
994
+ }
995
+ ]
996
+ }
997
+ }
998
+ ),
999
+ testkit.createTest(
1000
+ /* GraphQL */
1001
+ `
1002
+ {
1003
+ products {
1004
+ id
1005
+ reviews {
1006
+ id
1007
+ }
1008
+ }
1009
+ }
1010
+ `,
1011
+ {
1012
+ data: {
1013
+ products: [
1014
+ {
1015
+ id: "p1",
1016
+ reviews: [
1017
+ {
1018
+ id: 1
1019
+ },
1020
+ {
1021
+ id: 2
1022
+ }
1023
+ ]
1024
+ },
1025
+ {
1026
+ id: "p3",
1027
+ reviews: []
1028
+ },
1029
+ {
1030
+ id: "p2",
1031
+ reviews: [
1032
+ {
1033
+ id: 3
1034
+ }
1035
+ ]
1036
+ },
1037
+ {
1038
+ id: "p4",
1039
+ reviews: []
1040
+ }
1041
+ ]
1042
+ }
1043
+ }
1044
+ ),
1045
+ testkit.createTest(
1046
+ /* GraphQL */
1047
+ `
1048
+ query ($title: Boolean = true) {
1049
+ products {
1050
+ id
1051
+ reviews {
1052
+ product {
1053
+ id
1054
+ ... on Book @include(if: $title) {
1055
+ title
1056
+ }
1057
+ ... on Magazine {
1058
+ sku
1059
+ }
1060
+ }
1061
+ }
1062
+ }
1063
+ }
1064
+ `,
1065
+ {
1066
+ data: {
1067
+ products: [
1068
+ {
1069
+ id: "p1",
1070
+ reviews: [
1071
+ {
1072
+ product: {
1073
+ id: "p1",
1074
+ title: "Book 1"
1075
+ }
1076
+ },
1077
+ {
1078
+ product: {
1079
+ id: "p1",
1080
+ title: "Book 1"
1081
+ }
1082
+ }
1083
+ ]
1084
+ },
1085
+ {
1086
+ id: "p3",
1087
+ reviews: []
1088
+ },
1089
+ {
1090
+ id: "p2",
1091
+ reviews: [
1092
+ {
1093
+ product: {
1094
+ id: "p2",
1095
+ sku: "sku-2"
1096
+ }
1097
+ }
1098
+ ]
1099
+ },
1100
+ {
1101
+ id: "p4",
1102
+ reviews: []
1103
+ }
1104
+ ]
1105
+ }
1106
+ }
1107
+ ),
1108
+ testkit.createTest(
1109
+ /* GraphQL */
1110
+ `
1111
+ query ($title: Boolean = false) {
1112
+ products {
1113
+ id
1114
+ reviews {
1115
+ product {
1116
+ id
1117
+ ... on Book @include(if: $title) {
1118
+ title
1119
+ }
1120
+ ... on Magazine {
1121
+ sku
1122
+ }
1123
+ }
1124
+ }
1125
+ }
1126
+ }
1127
+ `,
1128
+ {
1129
+ data: {
1130
+ products: [
1131
+ {
1132
+ id: "p1",
1133
+ reviews: [
1134
+ {
1135
+ product: {
1136
+ id: "p1"
1137
+ }
1138
+ },
1139
+ {
1140
+ product: {
1141
+ id: "p1"
1142
+ }
1143
+ }
1144
+ ]
1145
+ },
1146
+ {
1147
+ id: "p3",
1148
+ reviews: []
1149
+ },
1150
+ {
1151
+ id: "p2",
1152
+ reviews: [
1153
+ {
1154
+ product: {
1155
+ id: "p2",
1156
+ sku: "sku-2"
1157
+ }
1158
+ }
1159
+ ]
1160
+ },
1161
+ {
1162
+ id: "p4",
1163
+ reviews: []
1164
+ }
1165
+ ]
1166
+ }
1167
+ }
1168
+ ),
1169
+ testkit.createTest(
1170
+ /* GraphQL */
1171
+ `
1172
+ query ($title: Boolean = false) {
1173
+ products {
1174
+ id
1175
+ reviews {
1176
+ product {
1177
+ id
1178
+ ... on Book @skip(if: $title) {
1179
+ title
1180
+ }
1181
+ ... on Magazine {
1182
+ sku
1183
+ }
1184
+ }
1185
+ }
1186
+ }
1187
+ }
1188
+ `,
1189
+ {
1190
+ data: {
1191
+ products: [
1192
+ {
1193
+ id: "p1",
1194
+ reviews: [
1195
+ {
1196
+ product: {
1197
+ id: "p1",
1198
+ title: "Book 1"
1199
+ }
1200
+ },
1201
+ {
1202
+ product: {
1203
+ id: "p1",
1204
+ title: "Book 1"
1205
+ }
1206
+ }
1207
+ ]
1208
+ },
1209
+ {
1210
+ id: "p3",
1211
+ reviews: []
1212
+ },
1213
+ {
1214
+ id: "p2",
1215
+ reviews: [
1216
+ {
1217
+ product: {
1218
+ id: "p2",
1219
+ sku: "sku-2"
1220
+ }
1221
+ }
1222
+ ]
1223
+ },
1224
+ {
1225
+ id: "p4",
1226
+ reviews: []
1227
+ }
1228
+ ]
1229
+ }
1230
+ }
1231
+ ),
1232
+ testkit.createTest(
1233
+ /* GraphQL */
1234
+ `
1235
+ query ($title: Boolean = true) {
1236
+ products {
1237
+ id
1238
+ reviews {
1239
+ product {
1240
+ id
1241
+ ... on Book @skip(if: $title) {
1242
+ title
1243
+ }
1244
+ ... on Magazine {
1245
+ sku
1246
+ }
1247
+ }
1248
+ }
1249
+ }
1250
+ }
1251
+ `,
1252
+ {
1253
+ data: {
1254
+ products: [
1255
+ {
1256
+ id: "p1",
1257
+ reviews: [
1258
+ {
1259
+ product: {
1260
+ id: "p1"
1261
+ }
1262
+ },
1263
+ {
1264
+ product: {
1265
+ id: "p1"
1266
+ }
1267
+ }
1268
+ ]
1269
+ },
1270
+ {
1271
+ id: "p3",
1272
+ reviews: []
1273
+ },
1274
+ {
1275
+ id: "p2",
1276
+ reviews: [
1277
+ {
1278
+ product: {
1279
+ id: "p2",
1280
+ sku: "sku-2"
1281
+ }
1282
+ }
1283
+ ]
1284
+ },
1285
+ {
1286
+ id: "p4",
1287
+ reviews: []
1288
+ }
1289
+ ]
1290
+ }
1291
+ }
1292
+ ),
1293
+ testkit.createTest(
1294
+ /* GraphQL */
1295
+ `
1296
+ query ($title: Boolean = true) {
1297
+ products {
1298
+ id
1299
+ reviews {
1300
+ product {
1301
+ id
1302
+ ... on Book @skip(if: $title) {
1303
+ title
1304
+ }
1305
+ ... on Book {
1306
+ sku
1307
+ }
1308
+ ... on Magazine {
1309
+ sku
1310
+ }
1311
+ }
1312
+ }
1313
+ }
1314
+ }
1315
+ `,
1316
+ {
1317
+ data: {
1318
+ products: [
1319
+ {
1320
+ id: "p1",
1321
+ reviews: [
1322
+ {
1323
+ product: {
1324
+ id: "p1",
1325
+ sku: "sku-1"
1326
+ }
1327
+ },
1328
+ {
1329
+ product: {
1330
+ id: "p1",
1331
+ sku: "sku-1"
1332
+ }
1333
+ }
1334
+ ]
1335
+ },
1336
+ {
1337
+ id: "p3",
1338
+ reviews: []
1339
+ },
1340
+ {
1341
+ id: "p2",
1342
+ reviews: [
1343
+ {
1344
+ product: {
1345
+ id: "p2",
1346
+ sku: "sku-2"
1347
+ }
1348
+ }
1349
+ ]
1350
+ },
1351
+ {
1352
+ id: "p4",
1353
+ reviews: []
1354
+ }
1355
+ ]
1356
+ }
1357
+ }
1358
+ ),
1359
+ testkit.createTest(
1360
+ /* GraphQL */
1361
+ `
1362
+ query ($title: Boolean = false) {
1363
+ products {
1364
+ id
1365
+ reviews {
1366
+ product {
1367
+ id
1368
+ ... on Book @skip(if: $title) {
1369
+ title
1370
+ }
1371
+ ... on Book {
1372
+ sku
1373
+ }
1374
+ ... on Magazine {
1375
+ sku
1376
+ }
1377
+ }
1378
+ }
1379
+ }
1380
+ }
1381
+ `,
1382
+ {
1383
+ data: {
1384
+ products: [
1385
+ {
1386
+ id: "p1",
1387
+ reviews: [
1388
+ {
1389
+ product: {
1390
+ id: "p1",
1391
+ title: "Book 1",
1392
+ sku: "sku-1"
1393
+ }
1394
+ },
1395
+ {
1396
+ product: {
1397
+ id: "p1",
1398
+ title: "Book 1",
1399
+ sku: "sku-1"
1400
+ }
1401
+ }
1402
+ ]
1403
+ },
1404
+ {
1405
+ id: "p3",
1406
+ reviews: []
1407
+ },
1408
+ {
1409
+ id: "p2",
1410
+ reviews: [
1411
+ {
1412
+ product: {
1413
+ id: "p2",
1414
+ sku: "sku-2"
1415
+ }
1416
+ }
1417
+ ]
1418
+ },
1419
+ {
1420
+ id: "p4",
1421
+ reviews: []
1422
+ }
1423
+ ]
1424
+ }
1425
+ }
1426
+ ),
1427
+ testkit.createTest(
1428
+ /* GraphQL */
1429
+ `
1430
+ query ($title: Boolean = true) {
1431
+ products {
1432
+ id
1433
+ reviews {
1434
+ product {
1435
+ id
1436
+ ... on Book @include(if: $title) {
1437
+ title
1438
+ ... on Book {
1439
+ sku
1440
+ }
1441
+ }
1442
+ ... on Magazine {
1443
+ sku
1444
+ }
1445
+ }
1446
+ }
1447
+ }
1448
+ }
1449
+ `,
1450
+ {
1451
+ data: {
1452
+ products: [
1453
+ {
1454
+ id: "p1",
1455
+ reviews: [
1456
+ {
1457
+ product: {
1458
+ id: "p1",
1459
+ title: "Book 1",
1460
+ sku: "sku-1"
1461
+ }
1462
+ },
1463
+ {
1464
+ product: {
1465
+ id: "p1",
1466
+ title: "Book 1",
1467
+ sku: "sku-1"
1468
+ }
1469
+ }
1470
+ ]
1471
+ },
1472
+ {
1473
+ id: "p3",
1474
+ reviews: []
1475
+ },
1476
+ {
1477
+ id: "p2",
1478
+ reviews: [
1479
+ {
1480
+ product: {
1481
+ id: "p2",
1482
+ sku: "sku-2"
1483
+ }
1484
+ }
1485
+ ]
1486
+ },
1487
+ {
1488
+ id: "p4",
1489
+ reviews: []
1490
+ }
1491
+ ]
1492
+ }
1493
+ }
1494
+ ),
1495
+ testkit.createTest(
1496
+ /* GraphQL */
1497
+ `
1498
+ query ($title: Boolean = true) {
1499
+ products {
1500
+ id
1501
+ reviews {
1502
+ product {
1503
+ id
1504
+ ... on Book @include(if: $title) {
1505
+ title
1506
+ ... on Book @skip(if: $title) {
1507
+ sku
1508
+ }
1509
+ }
1510
+ ... on Magazine {
1511
+ sku
1512
+ }
1513
+ }
1514
+ }
1515
+ }
1516
+ }
1517
+ `,
1518
+ {
1519
+ data: {
1520
+ products: [
1521
+ {
1522
+ id: "p1",
1523
+ reviews: [
1524
+ {
1525
+ product: {
1526
+ id: "p1",
1527
+ title: "Book 1"
1528
+ }
1529
+ },
1530
+ {
1531
+ product: {
1532
+ id: "p1",
1533
+ title: "Book 1"
1534
+ }
1535
+ }
1536
+ ]
1537
+ },
1538
+ {
1539
+ id: "p3",
1540
+ reviews: []
1541
+ },
1542
+ {
1543
+ id: "p2",
1544
+ reviews: [
1545
+ {
1546
+ product: {
1547
+ id: "p2",
1548
+ sku: "sku-2"
1549
+ }
1550
+ }
1551
+ ]
1552
+ },
1553
+ {
1554
+ id: "p4",
1555
+ reviews: []
1556
+ }
1557
+ ]
1558
+ }
1559
+ }
1560
+ ),
1561
+ testkit.createTest(
1562
+ /* GraphQL */
1563
+ `
1564
+ {
1565
+ products {
1566
+ id
1567
+ reviews {
1568
+ product {
1569
+ id
1570
+ ... on Magazine {
1571
+ publisherType {
1572
+ ...Publisher
1573
+ }
1574
+ }
1575
+ ... on Book {
1576
+ publisherType {
1577
+ ...Publisher
1578
+ }
1579
+ }
1580
+ }
1581
+ }
1582
+ }
1583
+ }
1584
+
1585
+ fragment Publisher on PublisherType {
1586
+ ... on Agency {
1587
+ id
1588
+ companyName
1589
+ }
1590
+ ... on Self {
1591
+ email
1592
+ }
1593
+ }
1594
+ `,
1595
+ {
1596
+ data: {
1597
+ products: [
1598
+ {
1599
+ id: "p1",
1600
+ reviews: [
1601
+ {
1602
+ product: {
1603
+ id: "p1",
1604
+ publisherType: {
1605
+ email: "u1@example.com"
1606
+ }
1607
+ }
1608
+ },
1609
+ {
1610
+ product: {
1611
+ id: "p1",
1612
+ publisherType: {
1613
+ email: "u1@example.com"
1614
+ }
1615
+ }
1616
+ }
1617
+ ]
1618
+ },
1619
+ {
1620
+ id: "p3",
1621
+ reviews: []
1622
+ },
1623
+ {
1624
+ id: "p2",
1625
+ reviews: [
1626
+ {
1627
+ product: {
1628
+ id: "p2",
1629
+ publisherType: {
1630
+ id: "a1",
1631
+ companyName: "Agency 1"
1632
+ }
1633
+ }
1634
+ }
1635
+ ]
1636
+ },
1637
+ {
1638
+ id: "p4",
1639
+ reviews: []
1640
+ }
1641
+ ]
1642
+ }
1643
+ }
1644
+ ),
1645
+ testkit.createTest(
1646
+ /* GraphQL */
1647
+ `
1648
+ {
1649
+ products {
1650
+ id
1651
+ reviews {
1652
+ product {
1653
+ id
1654
+ ... on Magazine {
1655
+ publisherType {
1656
+ ...Publisher
1657
+ }
1658
+ }
1659
+ ... on Book {
1660
+ publisherType {
1661
+ ...Publisher
1662
+ }
1663
+ }
1664
+ }
1665
+ }
1666
+ }
1667
+ }
1668
+
1669
+ fragment Publisher on PublisherType {
1670
+ ... on Agency {
1671
+ id
1672
+ companyName
1673
+ }
1674
+ ... on Self {
1675
+ email
1676
+ }
1677
+ ... on Group {
1678
+ name
1679
+ }
1680
+ }
1681
+ `,
1682
+ {
1683
+ data: {
1684
+ products: [
1685
+ {
1686
+ id: "p1",
1687
+ reviews: [
1688
+ {
1689
+ product: {
1690
+ id: "p1",
1691
+ publisherType: {
1692
+ email: "u1@example.com"
1693
+ }
1694
+ }
1695
+ },
1696
+ {
1697
+ product: {
1698
+ id: "p1",
1699
+ publisherType: {
1700
+ email: "u1@example.com"
1701
+ }
1702
+ }
1703
+ }
1704
+ ]
1705
+ },
1706
+ {
1707
+ id: "p3",
1708
+ reviews: []
1709
+ },
1710
+ {
1711
+ id: "p2",
1712
+ reviews: [
1713
+ {
1714
+ product: {
1715
+ id: "p2",
1716
+ publisherType: {
1717
+ id: "a1",
1718
+ companyName: "Agency 1"
1719
+ }
1720
+ }
1721
+ }
1722
+ ]
1723
+ },
1724
+ {
1725
+ id: "p4",
1726
+ reviews: []
1727
+ }
1728
+ ]
1729
+ }
1730
+ }
1731
+ ),
1732
+ testkit.createTest(
1733
+ /* GraphQL */
1734
+ `
1735
+ {
1736
+ products {
1737
+ id
1738
+ reviews {
1739
+ product {
1740
+ id
1741
+ ... on Magazine {
1742
+ publisherType {
1743
+ ...Publisher
1744
+ }
1745
+ }
1746
+ ... on Book {
1747
+ publisherType {
1748
+ ...Publisher
1749
+ }
1750
+ }
1751
+ }
1752
+ }
1753
+ }
1754
+ }
1755
+
1756
+ fragment Publisher on PublisherType {
1757
+ ... on Agency {
1758
+ emailObj: email {
1759
+ address
1760
+ }
1761
+ }
1762
+ ... on Self {
1763
+ emailStr: email
1764
+ }
1765
+ ... on Group {
1766
+ emailStr: email
1767
+ }
1768
+ }
1769
+ `,
1770
+ {
1771
+ data: {
1772
+ products: [
1773
+ {
1774
+ id: "p1",
1775
+ reviews: [
1776
+ {
1777
+ product: {
1778
+ id: "p1",
1779
+ publisherType: {
1780
+ emailStr: "u1@example.com"
1781
+ }
1782
+ }
1783
+ },
1784
+ {
1785
+ product: {
1786
+ id: "p1",
1787
+ publisherType: {
1788
+ emailStr: "u1@example.com"
1789
+ }
1790
+ }
1791
+ }
1792
+ ]
1793
+ },
1794
+ {
1795
+ id: "p3",
1796
+ reviews: []
1797
+ },
1798
+ {
1799
+ id: "p2",
1800
+ reviews: [
1801
+ {
1802
+ product: {
1803
+ id: "p2",
1804
+ publisherType: {
1805
+ emailObj: {
1806
+ address: "a1@example.com"
1807
+ }
1808
+ }
1809
+ }
1810
+ }
1811
+ ]
1812
+ },
1813
+ {
1814
+ id: "p4",
1815
+ reviews: []
1816
+ }
1817
+ ]
1818
+ }
1819
+ }
1820
+ )
1821
+ ];
1822
+
1823
+ var index = testkit.serve(
1824
+ "abstract-types",
1825
+ [
1826
+ agencySubgraph,
1827
+ inventorySubgraph,
1828
+ booksSubgraph,
1829
+ usersSubgraph,
1830
+ reviewsSubgraph,
1831
+ productsSubgraph,
1832
+ magazinesSubgraph
1833
+ ],
1834
+ test
1835
+ );
1836
+
1837
+ exports.default = index;