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