@graphql-hive/federation-gateway-audit 0.0.0 → 0.0.1
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.
- package/.github/workflows/ci.yaml +4 -4
- package/.github/workflows/release.yml +3 -3
- package/CHANGELOG.md +10 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +8 -4
- package/src/cli.ts +700 -0
- package/src/env.ts +13 -0
- package/src/index.ts +262 -0
- package/src/subgraph.ts +113 -0
- package/src/summary.ts +237 -0
- package/src/supergraph.ts +195 -0
- package/src/test-suites/abstract-types/agency.subgraph.ts +43 -0
- package/src/test-suites/abstract-types/books.subgraph.ts +47 -0
- package/src/test-suites/abstract-types/data.ts +120 -0
- package/src/test-suites/abstract-types/index.ts +23 -0
- package/src/test-suites/abstract-types/inventory.subgraph.ts +142 -0
- package/src/test-suites/abstract-types/magazines.subgraph.ts +47 -0
- package/src/test-suites/abstract-types/products.subgraph.ts +204 -0
- package/src/test-suites/abstract-types/reviews.subgraph.ts +159 -0
- package/src/test-suites/abstract-types/test.ts +1084 -0
- package/src/test-suites/abstract-types/users.subgraph.ts +31 -0
- package/src/test-suites/child-type-mismatch/a.subgraph.ts +27 -0
- package/src/test-suites/child-type-mismatch/b.subgraph.ts +51 -0
- package/src/test-suites/child-type-mismatch/data.ts +6 -0
- package/src/test-suites/child-type-mismatch/index.ts +6 -0
- package/{dist/index-Ca0FeU7u.js → src/test-suites/child-type-mismatch/test.ts} +79 -178
- package/src/test-suites/circular-reference-interface/a.subgraph.ts +55 -0
- package/src/test-suites/circular-reference-interface/b.subgraph.ts +35 -0
- package/src/test-suites/circular-reference-interface/data.ts +17 -0
- package/src/test-suites/circular-reference-interface/index.ts +6 -0
- package/src/test-suites/circular-reference-interface/test.ts +78 -0
- package/src/test-suites/complex-entity-call/data.ts +27 -0
- package/src/test-suites/complex-entity-call/index.ts +12 -0
- package/src/test-suites/complex-entity-call/link.subgraph.ts +36 -0
- package/src/test-suites/complex-entity-call/list.subgraph.ts +44 -0
- package/src/test-suites/complex-entity-call/price.subgraph.ts +107 -0
- package/src/test-suites/complex-entity-call/products.subgraph.ts +65 -0
- package/src/test-suites/complex-entity-call/test.ts +74 -0
- package/src/test-suites/corrupted-supergraph-node-id/a.subgraph.ts +112 -0
- package/src/test-suites/corrupted-supergraph-node-id/b.subgraph.ts +113 -0
- package/src/test-suites/corrupted-supergraph-node-id/data.ts +16 -0
- package/src/test-suites/corrupted-supergraph-node-id/index.ts +6 -0
- package/src/test-suites/corrupted-supergraph-node-id/test.ts +223 -0
- package/src/test-suites/enum-intersection/a.subgraph.ts +46 -0
- package/src/test-suites/enum-intersection/b.subgraph.ts +51 -0
- package/src/test-suites/enum-intersection/data.ts +10 -0
- package/src/test-suites/enum-intersection/index.ts +6 -0
- package/src/test-suites/enum-intersection/test.ts +108 -0
- package/src/test-suites/fed1-external-extends/a.subgraph.ts +51 -0
- package/src/test-suites/fed1-external-extends/b.subgraph.ts +48 -0
- package/src/test-suites/fed1-external-extends/data.ts +14 -0
- package/src/test-suites/fed1-external-extends/index.ts +6 -0
- package/src/test-suites/fed1-external-extends/test.ts +90 -0
- package/src/test-suites/fed1-external-extends-resolvable/a.subgraph.ts +40 -0
- package/src/test-suites/fed1-external-extends-resolvable/b.subgraph.ts +52 -0
- package/src/test-suites/fed1-external-extends-resolvable/data.ts +9 -0
- package/src/test-suites/fed1-external-extends-resolvable/index.ts +6 -0
- package/src/test-suites/fed1-external-extends-resolvable/test.ts +28 -0
- package/src/test-suites/fed1-external-extension/a.subgraph.ts +51 -0
- package/src/test-suites/fed1-external-extension/b.subgraph.ts +48 -0
- package/src/test-suites/fed1-external-extension/data.ts +14 -0
- package/src/test-suites/fed1-external-extension/index.ts +6 -0
- package/src/test-suites/fed1-external-extension/test.ts +90 -0
- package/src/test-suites/fed2-external-extends/a.subgraph.ts +57 -0
- package/src/test-suites/fed2-external-extends/b.subgraph.ts +54 -0
- package/src/test-suites/fed2-external-extends/data.ts +14 -0
- package/src/test-suites/fed2-external-extends/index.ts +6 -0
- package/src/test-suites/fed2-external-extends/test.ts +90 -0
- package/src/test-suites/fed2-external-extension/a.subgraph.ts +57 -0
- package/src/test-suites/fed2-external-extension/b.subgraph.ts +54 -0
- package/src/test-suites/fed2-external-extension/data.ts +14 -0
- package/src/test-suites/fed2-external-extension/index.ts +6 -0
- package/src/test-suites/fed2-external-extension/test.ts +90 -0
- package/src/test-suites/include-skip/a.subgraph.ts +42 -0
- package/src/test-suites/include-skip/b.subgraph.ts +47 -0
- package/src/test-suites/include-skip/c.subgraph.ts +65 -0
- package/src/test-suites/include-skip/data.ts +6 -0
- package/src/test-suites/include-skip/index.ts +7 -0
- package/src/test-suites/include-skip/test.ts +74 -0
- package/src/test-suites/input-object-intersection/a.subgraph.ts +47 -0
- package/src/test-suites/input-object-intersection/b.subgraph.ts +51 -0
- package/src/test-suites/input-object-intersection/data.ts +10 -0
- package/src/test-suites/input-object-intersection/index.ts +6 -0
- package/src/test-suites/input-object-intersection/test.ts +49 -0
- package/src/test-suites/interface-object-indirect-extension/author.subgraph.ts +39 -0
- package/src/test-suites/interface-object-indirect-extension/index.ts +11 -0
- package/src/test-suites/interface-object-indirect-extension/media.subgraph.ts +63 -0
- package/src/test-suites/interface-object-indirect-extension/playlist.subgraph.ts +48 -0
- package/src/test-suites/interface-object-indirect-extension/test.ts +57 -0
- package/src/test-suites/interface-object-with-requires/a.subgraph.ts +68 -0
- package/src/test-suites/interface-object-with-requires/b.subgraph.ts +61 -0
- package/src/test-suites/interface-object-with-requires/data.ts +14 -0
- package/src/test-suites/interface-object-with-requires/index.ts +6 -0
- package/src/test-suites/interface-object-with-requires/test.ts +206 -0
- package/src/test-suites/keys-mashup/a.subgraph.ts +46 -0
- package/src/test-suites/keys-mashup/b.subgraph.ts +118 -0
- package/src/test-suites/keys-mashup/data.ts +43 -0
- package/src/test-suites/keys-mashup/index.ts +6 -0
- package/src/test-suites/keys-mashup/test.ts +32 -0
- package/src/test-suites/mutations/a.subgraph.ts +136 -0
- package/src/test-suites/mutations/b.subgraph.ts +107 -0
- package/src/test-suites/mutations/c.subgraph.ts +26 -0
- package/src/test-suites/mutations/data.ts +91 -0
- package/src/test-suites/mutations/index.ts +7 -0
- package/src/test-suites/mutations/test.ts +94 -0
- package/src/test-suites/mysterious-external/data.ts +12 -0
- package/src/test-suites/mysterious-external/index.ts +6 -0
- package/src/test-suites/mysterious-external/price.subgraph.ts +55 -0
- package/src/test-suites/mysterious-external/product.subgraph.ts +45 -0
- package/src/test-suites/mysterious-external/test.ts +51 -0
- package/src/test-suites/nested-provides/all-products.subgraph.ts +37 -0
- package/src/test-suites/nested-provides/category.subgraph.ts +104 -0
- package/src/test-suites/nested-provides/data.ts +28 -0
- package/src/test-suites/nested-provides/index.ts +11 -0
- package/src/test-suites/nested-provides/subcategories.subgraph.ts +89 -0
- package/src/test-suites/nested-provides/test.ts +122 -0
- package/src/test-suites/node/data.ts +23 -0
- package/src/test-suites/node/index.ts +7 -0
- package/src/test-suites/node/node-two.ts +49 -0
- package/src/test-suites/node/node.subgraph.ts +68 -0
- package/src/test-suites/node/test.ts +28 -0
- package/src/test-suites/node/types.subgraph.ts +58 -0
- package/src/test-suites/non-resolvable-interface-object/a.subgraph.ts +40 -0
- package/src/test-suites/non-resolvable-interface-object/b.subgraph.ts +55 -0
- package/src/test-suites/non-resolvable-interface-object/data.ts +7 -0
- package/src/test-suites/non-resolvable-interface-object/index.ts +6 -0
- package/src/test-suites/non-resolvable-interface-object/test.ts +113 -0
- package/src/test-suites/null-keys/a.subgraph.ts +40 -0
- package/src/test-suites/null-keys/b.subgraph.ts +42 -0
- package/src/test-suites/null-keys/c.subgraph.ts +48 -0
- package/src/test-suites/null-keys/data.ts +32 -0
- package/src/test-suites/null-keys/index.ts +7 -0
- package/src/test-suites/null-keys/test.ts +46 -0
- package/src/test-suites/override-type-interface/a.subgraph.ts +47 -0
- package/src/test-suites/override-type-interface/b.subgraph.ts +73 -0
- package/src/test-suites/override-type-interface/data.ts +27 -0
- package/src/test-suites/override-type-interface/index.ts +6 -0
- package/src/test-suites/override-type-interface/test.ts +94 -0
- package/src/test-suites/override-with-requires/a.subgraph.ts +55 -0
- package/src/test-suites/override-with-requires/b.subgraph.ts +42 -0
- package/src/test-suites/override-with-requires/c.subgraph.ts +55 -0
- package/src/test-suites/override-with-requires/data.ts +14 -0
- package/src/test-suites/override-with-requires/index.ts +7 -0
- package/src/test-suites/override-with-requires/test.ts +98 -0
- package/src/test-suites/parent-entity-call/a.subgraph.ts +90 -0
- package/src/test-suites/parent-entity-call/b.subgraph.ts +68 -0
- package/src/test-suites/parent-entity-call/c.subgraph.ts +56 -0
- package/src/test-suites/parent-entity-call/data.ts +34 -0
- package/src/test-suites/parent-entity-call/index.ts +7 -0
- package/src/test-suites/parent-entity-call/test.ts +52 -0
- package/src/test-suites/parent-entity-call-complex/a.subgraph.ts +29 -0
- package/src/test-suites/parent-entity-call-complex/b.subgraph.ts +32 -0
- package/src/test-suites/parent-entity-call-complex/c.subgraph.ts +22 -0
- package/src/test-suites/parent-entity-call-complex/d.subgraph.ts +35 -0
- package/src/test-suites/parent-entity-call-complex/index.ts +8 -0
- package/src/test-suites/parent-entity-call-complex/test.ts +32 -0
- package/src/test-suites/provides-on-interface/a.subgraph.ts +95 -0
- package/src/test-suites/provides-on-interface/b.subgraph.ts +65 -0
- package/src/test-suites/provides-on-interface/c.subgraph.ts +119 -0
- package/src/test-suites/provides-on-interface/data.ts +24 -0
- package/src/test-suites/provides-on-interface/index.ts +7 -0
- package/src/test-suites/provides-on-interface/test.ts +68 -0
- package/src/test-suites/provides-on-union/a.subgraph.ts +41 -0
- package/src/test-suites/provides-on-union/b.subgraph.ts +47 -0
- package/src/test-suites/provides-on-union/c.subgraph.ts +59 -0
- package/src/test-suites/provides-on-union/data.ts +12 -0
- package/src/test-suites/provides-on-union/index.ts +7 -0
- package/src/test-suites/provides-on-union/test.ts +62 -0
- package/src/test-suites/requires-circular/a.subgraph.ts +72 -0
- package/src/test-suites/requires-circular/b.subgraph.ts +46 -0
- package/src/test-suites/requires-circular/data.ts +25 -0
- package/src/test-suites/requires-circular/index.ts +6 -0
- package/src/test-suites/requires-circular/test.ts +46 -0
- package/src/test-suites/requires-interface/a.subgraph.ts +92 -0
- package/src/test-suites/requires-interface/b.subgraph.ts +82 -0
- package/src/test-suites/requires-interface/data.ts +27 -0
- package/src/test-suites/requires-interface/index.ts +6 -0
- package/src/test-suites/requires-interface/test.ts +96 -0
- package/src/test-suites/requires-requires/a.subgraph.ts +33 -0
- package/src/test-suites/requires-requires/b.subgraph.ts +42 -0
- package/src/test-suites/requires-requires/c.subgraph.ts +65 -0
- package/src/test-suites/requires-requires/d.subgraph.ts +71 -0
- package/src/test-suites/requires-requires/data.ts +7 -0
- package/src/test-suites/requires-requires/index.ts +8 -0
- package/src/test-suites/requires-requires/test.ts +88 -0
- package/src/test-suites/requires-with-argument/a.subgraph.ts +68 -0
- package/src/test-suites/requires-with-argument/b.subgraph.ts +55 -0
- package/src/test-suites/requires-with-argument/c.subgraph.ts +71 -0
- package/src/test-suites/requires-with-argument/d.subgraph.ts +97 -0
- package/src/test-suites/requires-with-argument/data.ts +81 -0
- package/src/test-suites/requires-with-argument/index.ts +8 -0
- package/src/test-suites/requires-with-argument/test.ts +192 -0
- package/src/test-suites/requires-with-argument-conflict/a.subgraph.ts +79 -0
- package/src/test-suites/requires-with-argument-conflict/b.subgraph.ts +60 -0
- package/src/test-suites/requires-with-argument-conflict/data.ts +20 -0
- package/src/test-suites/requires-with-argument-conflict/index.ts +6 -0
- package/src/test-suites/requires-with-argument-conflict/test.ts +37 -0
- package/src/test-suites/requires-with-fragments/a.subgraph.ts +81 -0
- package/src/test-suites/requires-with-fragments/b.subgraph.ts +151 -0
- package/src/test-suites/requires-with-fragments/data.ts +30 -0
- package/src/test-suites/requires-with-fragments/index.ts +6 -0
- package/src/test-suites/requires-with-fragments/test.ts +138 -0
- package/src/test-suites/shared-root/category.subgraph.ts +45 -0
- package/src/test-suites/shared-root/data.ts +22 -0
- package/src/test-suites/shared-root/index.ts +7 -0
- package/src/test-suites/shared-root/name.subgraph.ts +46 -0
- package/src/test-suites/shared-root/price.subgraph.ts +46 -0
- package/src/test-suites/shared-root/test.ts +94 -0
- package/src/test-suites/simple-entity-call/data.ts +12 -0
- package/src/test-suites/simple-entity-call/email.subgraph.ts +42 -0
- package/src/test-suites/simple-entity-call/index.ts +6 -0
- package/src/test-suites/simple-entity-call/nickname.subgraph.ts +32 -0
- package/src/test-suites/simple-entity-call/test.ts +23 -0
- package/src/test-suites/simple-inaccessible/age.subgraph.ts +45 -0
- package/src/test-suites/simple-inaccessible/data.ts +12 -0
- package/src/test-suites/simple-inaccessible/friends.subgraph.ts +68 -0
- package/src/test-suites/simple-inaccessible/index.ts +6 -0
- package/src/test-suites/simple-inaccessible/test.ts +124 -0
- package/src/test-suites/simple-interface-object/a.subgraph.ts +163 -0
- package/src/test-suites/simple-interface-object/b.subgraph.ts +89 -0
- package/src/test-suites/simple-interface-object/c.subgraph.ts +48 -0
- package/src/test-suites/simple-interface-object/data.ts +38 -0
- package/src/test-suites/simple-interface-object/index.ts +7 -0
- package/src/test-suites/simple-interface-object/test.ts +367 -0
- package/src/test-suites/simple-override/a.subgraph.ts +49 -0
- package/src/test-suites/simple-override/b.subgraph.ts +46 -0
- package/src/test-suites/simple-override/data.ts +10 -0
- package/src/test-suites/simple-override/index.ts +6 -0
- package/src/test-suites/simple-override/test.ts +51 -0
- package/src/test-suites/simple-requires-provides/accounts.subgraph.ts +48 -0
- package/src/test-suites/simple-requires-provides/data.ts +44 -0
- package/src/test-suites/simple-requires-provides/index.ts +12 -0
- package/src/test-suites/simple-requires-provides/inventory.subgraph.ts +59 -0
- package/src/test-suites/simple-requires-provides/products.subgraph.ts +48 -0
- package/src/test-suites/simple-requires-provides/reviews.subgraph.ts +106 -0
- package/src/test-suites/simple-requires-provides/test.ts +372 -0
- package/src/test-suites/typename/a.subgraph.ts +76 -0
- package/src/test-suites/typename/b.subgraph.ts +50 -0
- package/src/test-suites/typename/data.ts +14 -0
- package/src/test-suites/typename/index.ts +6 -0
- package/src/test-suites/typename/test.ts +132 -0
- package/src/test-suites/unavailable-override/a.subgraph.ts +46 -0
- package/src/test-suites/unavailable-override/b.subgraph.ts +46 -0
- package/src/test-suites/unavailable-override/data.ts +10 -0
- package/src/test-suites/unavailable-override/index.ts +6 -0
- package/src/test-suites/unavailable-override/test.ts +51 -0
- package/src/test-suites/union-interface-distributed/a.subgraph.ts +126 -0
- package/src/test-suites/union-interface-distributed/b.subgraph.ts +39 -0
- package/src/test-suites/union-interface-distributed/data.ts +26 -0
- package/src/test-suites/union-interface-distributed/index.ts +6 -0
- package/src/test-suites/union-interface-distributed/test.ts +244 -0
- package/src/test-suites/union-intersection/README.md +3 -0
- package/src/test-suites/union-intersection/a.subgraph.ts +83 -0
- package/src/test-suites/union-intersection/b.subgraph.ts +79 -0
- package/src/test-suites/union-intersection/data.ts +7 -0
- package/src/test-suites/union-intersection/index.ts +6 -0
- package/{dist/index-Ytb942t9.js → src/test-suites/union-intersection/test.ts} +74 -260
- package/src/test.ts +98 -0
- package/src/testkit.ts +31 -0
- package/.changeset/@graphql-hive_federation-gateway-audit-293-dependencies.md +0 -5
- package/.changeset/funky-times-cry.md +0 -5
- package/dist/index--3rcSZqA.js +0 -227
- package/dist/index-0MDIXUzP.cjs +0 -589
- package/dist/index-2oy7cA9A.js +0 -225
- package/dist/index-3BM15w2Y.mjs +0 -234
- package/dist/index-3CyAnc7j.js +0 -234
- package/dist/index-4swHVe9x.cjs +0 -507
- package/dist/index-6qNpP2wc.mjs +0 -238
- package/dist/index-A2YbwKzc.mjs +0 -288
- package/dist/index-B0coRevy.mjs +0 -337
- package/dist/index-B1NAc0TI.cjs +0 -215
- package/dist/index-B1WvIzTg.js +0 -371
- package/dist/index-B55AdoQy.js +0 -273
- package/dist/index-B7cr8XE-.js +0 -194
- package/dist/index-B7zN3YzE.cjs +0 -683
- package/dist/index-B9T896rB.mjs +0 -163
- package/dist/index-BEMScD_X.cjs +0 -173
- package/dist/index-BGC0_vWj.cjs +0 -335
- package/dist/index-BGUm947D.cjs +0 -229
- package/dist/index-BKcwbRZx.cjs +0 -339
- package/dist/index-BKpVb_h9.cjs +0 -236
- package/dist/index-BPFol6Ww.mjs +0 -129
- package/dist/index-BPza8i2Q.mjs +0 -213
- package/dist/index-BS7JyQSU.js +0 -250
- package/dist/index-BSWSgZCO.cjs +0 -252
- package/dist/index-BSwOAvti.js +0 -288
- package/dist/index-BWO8QbMB.mjs +0 -587
- package/dist/index-B_u5Boud.js +0 -333
- package/dist/index-BaH3FI9i.cjs +0 -361
- package/dist/index-BaluTf1I.cjs +0 -707
- package/dist/index-BcoW0aPo.cjs +0 -165
- package/dist/index-BdNZKlDU.js +0 -284
- package/dist/index-Bf81cAA1.mjs +0 -444
- package/dist/index-Bg3H3fgZ.js +0 -259
- package/dist/index-Bgl_1Y6Q.mjs +0 -681
- package/dist/index-BgryMCqm.mjs +0 -213
- package/dist/index-BiTzMTFn.js +0 -304
- package/dist/index-BjbmOyBP.cjs +0 -215
- package/dist/index-Bm8hqSRd.cjs +0 -168
- package/dist/index-BmQrhPXB.cjs +0 -131
- package/dist/index-BndUB2KV.mjs +0 -381
- package/dist/index-BpJZCoVH.mjs +0 -250
- package/dist/index-Br-Y1qC_.cjs +0 -446
- package/dist/index-BrFtcRgi.mjs +0 -194
- package/dist/index-Bu8SXnTf.mjs +0 -227
- package/dist/index-Bwh8HVkw.cjs +0 -384
- package/dist/index-BxK3Y72_.js +0 -227
- package/dist/index-BxPUzymh.cjs +0 -208
- package/dist/index-ByZa9qm8.mjs +0 -273
- package/dist/index-Bz_LTy1A.mjs +0 -222
- package/dist/index-C1GgHOiD.js +0 -228
- package/dist/index-C4Pk-zTm.mjs +0 -227
- package/dist/index-C6nkQ480.js +0 -225
- package/dist/index-C8Mu4K9Q.cjs +0 -383
- package/dist/index-CAJ9YPxc.js +0 -681
- package/dist/index-CD03pVUt.cjs +0 -373
- package/dist/index-CD8GiuIg.js +0 -227
- package/dist/index-CHB_0VqK.mjs +0 -333
- package/dist/index-CNvZCDZa.js +0 -166
- package/dist/index-COGhiFjk.mjs +0 -284
- package/dist/index-COIlelpZ.mjs +0 -262
- package/dist/index-CPu_XkjY.mjs +0 -304
- package/dist/index-CUFKuE64.js +0 -550
- package/dist/index-CW8h3l6M.js +0 -262
- package/dist/index-CWrng7Hd.mjs +0 -550
- package/dist/index-CXviN8qZ.cjs +0 -224
- package/dist/index-C_qaNb-X.mjs +0 -225
- package/dist/index-Cb3ImEjd.cjs +0 -165
- package/dist/index-Cc3vrs6_.mjs +0 -228
- package/dist/index-CcIXvx40.mjs +0 -171
- package/dist/index-CdaeeF3f.cjs +0 -306
- package/dist/index-Cj2ocjXI.cjs +0 -227
- package/dist/index-CkWEXzTN.js +0 -129
- package/dist/index-Ckhb9QAu.cjs +0 -264
- package/dist/index-CklJfQlf.cjs +0 -220
- package/dist/index-Cn0ZJkAv.mjs +0 -280
- package/dist/index-Cuw9ylL-.mjs +0 -371
- package/dist/index-CwOULUAt.mjs +0 -382
- package/dist/index-D-1dDKiZ.mjs +0 -227
- package/dist/index-D1Ip6ro6.js +0 -458
- package/dist/index-D5tEp8IU.js +0 -337
- package/dist/index-D7WuGKYY.cjs +0 -227
- package/dist/index-D8Dp6TnQ.cjs +0 -1837
- package/dist/index-D9OKpqgG.js +0 -381
- package/dist/index-DBMI2EcB.cjs +0 -170
- package/dist/index-DBRUKV0U.mjs +0 -225
- package/dist/index-DHRqE92a.cjs +0 -290
- package/dist/index-DJ3ndv3i.mjs +0 -705
- package/dist/index-DJXP-Gmp.js +0 -218
- package/dist/index-DJlXDQOY.cjs +0 -200
- package/dist/index-DLW4GEJl.cjs +0 -229
- package/dist/index-DM4ddIL6.js +0 -382
- package/dist/index-DN-ScBql.mjs +0 -458
- package/dist/index-DS86eFsI.mjs +0 -1835
- package/dist/index-DZws2w4w.cjs +0 -229
- package/dist/index-Dbb-jnWf.js +0 -206
- package/dist/index-DdXy_-T9.js +0 -444
- package/dist/index-DiDq1sL6.cjs +0 -240
- package/dist/index-DiuJQ9Mq.js +0 -198
- package/dist/index-Dk0q-ENv.mjs +0 -166
- package/dist/index-DlFElztE.mjs +0 -163
- package/dist/index-DlkxQ-B5.mjs +0 -359
- package/dist/index-Du5MxO_2.mjs +0 -505
- package/dist/index-DxHMqS-W.js +0 -117
- package/dist/index-DyTApTHI.cjs +0 -282
- package/dist/index-DzAewrkw.js +0 -238
- package/dist/index-EuKHpnHv.mjs +0 -117
- package/dist/index-FP6hvgSw.cjs +0 -552
- package/dist/index-GDSrKnPp.mjs +0 -198
- package/dist/index-GMCZo-KH.js +0 -222
- package/dist/index-IawHHRZX.mjs +0 -206
- package/dist/index-Jk7MG7tE.cjs +0 -286
- package/dist/index-KAC20a9r.js +0 -359
- package/dist/index-Ls2fI7y4.js +0 -163
- package/dist/index-NIEZaRYg.cjs +0 -261
- package/dist/index-PyaLRKuk.mjs +0 -168
- package/dist/index-QXYDkAsQ.cjs +0 -119
- package/dist/index-SmEIf5jz.mjs +0 -259
- package/dist/index-UVyXzNlG.js +0 -705
- package/dist/index-VvuhRvnC.mjs +0 -218
- package/dist/index-XZiO6uje.cjs +0 -275
- package/dist/index-YOlsBREZ.cjs +0 -230
- package/dist/index-_2dg_MWu.cjs +0 -460
- package/dist/index-eFEW10em.js +0 -213
- package/dist/index-f7FiDQMk.js +0 -171
- package/dist/index-fdDnq3vQ.js +0 -163
- package/dist/index-l8e8ip4U.js +0 -168
- package/dist/index-rn-_7-wp.cjs +0 -196
- package/dist/index-s27DHpTG.js +0 -1835
- package/dist/index-sbc7nDv3.js +0 -213
- package/dist/index-vHngHSlz.js +0 -280
- package/dist/testkit-C920qivh.js +0 -281
- package/dist/testkit-C920qivh.mjs +0 -281
- package/dist/testkit-D0rTQ6MD.cjs +0 -286
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { composeServices } from "@apollo/composition";
|
|
2
|
+
import { parse } from "graphql";
|
|
3
|
+
import type { createRouter } from "fets";
|
|
4
|
+
import { Response } from "fets";
|
|
5
|
+
import type { createSubgraph } from "./subgraph.js";
|
|
6
|
+
|
|
7
|
+
export function getSupergraph(
|
|
8
|
+
subgraphs: Array<{
|
|
9
|
+
name: string;
|
|
10
|
+
url: string;
|
|
11
|
+
typeDefs: string;
|
|
12
|
+
}>,
|
|
13
|
+
) {
|
|
14
|
+
const result = composeServices(
|
|
15
|
+
subgraphs.map((subgraph) => ({
|
|
16
|
+
name: subgraph.name,
|
|
17
|
+
typeDefs: parse(subgraph.typeDefs),
|
|
18
|
+
url: subgraph.url,
|
|
19
|
+
})),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
if (!result.supergraphSdl) {
|
|
23
|
+
result.errors?.forEach((error) => console.error(error.message));
|
|
24
|
+
throw new Error("Failed to compose supergraph");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return result.supergraphSdl;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function serve(
|
|
31
|
+
id: string,
|
|
32
|
+
subgraphs: Array<ReturnType<typeof createSubgraph>>,
|
|
33
|
+
tests:
|
|
34
|
+
| (() => Array<{
|
|
35
|
+
query: string;
|
|
36
|
+
expected: any;
|
|
37
|
+
}>)
|
|
38
|
+
| Array<{
|
|
39
|
+
query: string;
|
|
40
|
+
expected: any;
|
|
41
|
+
}>,
|
|
42
|
+
) {
|
|
43
|
+
return {
|
|
44
|
+
id,
|
|
45
|
+
createRoutes(router: ReturnType<typeof createRouter>) {
|
|
46
|
+
let subgraphNames = new Set<string>();
|
|
47
|
+
for (const subgraph of subgraphs) {
|
|
48
|
+
if (subgraphNames.has(subgraph.name)) {
|
|
49
|
+
throw new Error(`Duplicate subgraph name ${subgraph.name}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
subgraphNames.add(subgraph.name);
|
|
53
|
+
subgraph.createRoutes(id, router);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function serveSupergraph(request: { url: string; parsedUrl: URL }) {
|
|
57
|
+
const supergraph = getSupergraph(
|
|
58
|
+
subgraphs.map((subgraph) => ({
|
|
59
|
+
name: subgraph.name,
|
|
60
|
+
typeDefs: subgraph.typeDefs,
|
|
61
|
+
url: `${request.parsedUrl.origin}/${id}/${subgraph.name}`,
|
|
62
|
+
})),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const response = new Response(supergraph, {
|
|
66
|
+
status: 200,
|
|
67
|
+
headers: {
|
|
68
|
+
"Content-Type": "text/plain",
|
|
69
|
+
"Cache-Control":
|
|
70
|
+
"public, max-age=604800, stale-while-revalidate=432000",
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return response;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
router.route({
|
|
78
|
+
method: "GET",
|
|
79
|
+
path: `/${id}/supergraph`,
|
|
80
|
+
tags: [id],
|
|
81
|
+
description: "Supergraph SDL endpoint",
|
|
82
|
+
operationId: "supergraph",
|
|
83
|
+
schemas: {
|
|
84
|
+
responses: {
|
|
85
|
+
200: {
|
|
86
|
+
type: "string",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
handler(req) {
|
|
91
|
+
return serveSupergraph(req);
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
router.route({
|
|
96
|
+
method: "GET",
|
|
97
|
+
path: `/${id}/supergraph.graphql`,
|
|
98
|
+
tags: [id],
|
|
99
|
+
description: "Supergraph SDL endpoint",
|
|
100
|
+
operationId: "supergraph.graphql",
|
|
101
|
+
schemas: {
|
|
102
|
+
responses: {
|
|
103
|
+
200: {
|
|
104
|
+
type: "string",
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
handler(req) {
|
|
109
|
+
return serveSupergraph(req);
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
router.route({
|
|
114
|
+
method: "GET",
|
|
115
|
+
path: `/${id}/subgraphs`,
|
|
116
|
+
tags: [id],
|
|
117
|
+
description: "A list of subgraphs with their SDLs, URLs and names",
|
|
118
|
+
operationId: "subgraphs",
|
|
119
|
+
schemas: {
|
|
120
|
+
responses: {
|
|
121
|
+
200: {
|
|
122
|
+
type: "array",
|
|
123
|
+
items: {
|
|
124
|
+
type: "object",
|
|
125
|
+
properties: {
|
|
126
|
+
name: { type: "string" },
|
|
127
|
+
url: { type: "string" },
|
|
128
|
+
sdl: { type: "string" },
|
|
129
|
+
},
|
|
130
|
+
required: ["name", "url", "sdl"],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
handler(req) {
|
|
136
|
+
return Response.json(
|
|
137
|
+
subgraphs.map((subgraph) => ({
|
|
138
|
+
name: subgraph.name,
|
|
139
|
+
sdl: subgraph.typeDefs,
|
|
140
|
+
url: `${req.parsedUrl.origin}/${id}/${subgraph.name}`,
|
|
141
|
+
})),
|
|
142
|
+
);
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
router.route({
|
|
147
|
+
method: "GET",
|
|
148
|
+
path: `/${id}/tests`,
|
|
149
|
+
tags: [id],
|
|
150
|
+
description: "Endpoint with a list of tests",
|
|
151
|
+
operationId: "tests",
|
|
152
|
+
schemas: {
|
|
153
|
+
responses: {
|
|
154
|
+
200: {
|
|
155
|
+
type: "array",
|
|
156
|
+
items: {
|
|
157
|
+
type: "object",
|
|
158
|
+
properties: {
|
|
159
|
+
query: { type: "string" },
|
|
160
|
+
expected: {
|
|
161
|
+
type: "object",
|
|
162
|
+
properties: {
|
|
163
|
+
data: {
|
|
164
|
+
anyOf: [
|
|
165
|
+
{ type: "object" },
|
|
166
|
+
{
|
|
167
|
+
type: "null",
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
errors: {
|
|
172
|
+
type: "boolean",
|
|
173
|
+
description: "Indicates that errors are expected",
|
|
174
|
+
default: false,
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
additionalProperties: false,
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
additionalProperties: false,
|
|
181
|
+
required: ["query", "expected"],
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
handler() {
|
|
187
|
+
const testsArray = Array.isArray(tests) ? tests : tests();
|
|
188
|
+
return Response.json(testsArray);
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
return id;
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createSubgraph } from "../../subgraph.js";
|
|
2
|
+
import { agencies } from "./data.js";
|
|
3
|
+
|
|
4
|
+
export default createSubgraph("agency", {
|
|
5
|
+
typeDefs: /* GraphQL */ `
|
|
6
|
+
extend schema
|
|
7
|
+
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key"])
|
|
8
|
+
|
|
9
|
+
type Agency @key(fields: "id") {
|
|
10
|
+
id: ID!
|
|
11
|
+
companyName: String
|
|
12
|
+
email: Email
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type Email {
|
|
16
|
+
address: String
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type Group @key(fields: "id") {
|
|
20
|
+
id: ID!
|
|
21
|
+
name: String
|
|
22
|
+
email: String
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
extend union PublisherType = Agency | Group
|
|
26
|
+
`,
|
|
27
|
+
resolvers: {
|
|
28
|
+
Agency: {
|
|
29
|
+
__resolveReference(key: { id: string }) {
|
|
30
|
+
return agencies.find((a) => a.id === key.id);
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
Group: {
|
|
34
|
+
__resolveReference(key: { id: string }) {
|
|
35
|
+
return {
|
|
36
|
+
id: key.id,
|
|
37
|
+
name: "Group " + key.id,
|
|
38
|
+
email: "group" + key.id + "@example.com",
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createSubgraph } from "../../subgraph.js";
|
|
2
|
+
import { books } from "./data.js";
|
|
3
|
+
|
|
4
|
+
export default createSubgraph("books", {
|
|
5
|
+
typeDefs: /* GraphQL */ `
|
|
6
|
+
schema
|
|
7
|
+
@link(
|
|
8
|
+
url: "https://specs.apollo.dev/federation/v2.3"
|
|
9
|
+
import: ["@key", "@shareable", "@external", "@requires"]
|
|
10
|
+
) {
|
|
11
|
+
query: Query
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type Book @key(fields: "id") {
|
|
15
|
+
id: ID!
|
|
16
|
+
title: String
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type Query {
|
|
20
|
+
books: [Book]
|
|
21
|
+
}
|
|
22
|
+
`,
|
|
23
|
+
resolvers: {
|
|
24
|
+
Query: {
|
|
25
|
+
books() {
|
|
26
|
+
return books.map((book) => ({
|
|
27
|
+
__typename: "Book",
|
|
28
|
+
id: book.id,
|
|
29
|
+
title: book.title,
|
|
30
|
+
}));
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
Book: {
|
|
34
|
+
__resolveReference(key: { id: string }) {
|
|
35
|
+
const book = books.find((book) => book.id === key.id);
|
|
36
|
+
|
|
37
|
+
return book
|
|
38
|
+
? {
|
|
39
|
+
__typename: "Book",
|
|
40
|
+
id: book.id,
|
|
41
|
+
title: book.title,
|
|
42
|
+
}
|
|
43
|
+
: null;
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export const users = [
|
|
2
|
+
{
|
|
3
|
+
id: "u1",
|
|
4
|
+
email: "u1@example.com",
|
|
5
|
+
name: "u1-name",
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
id: "u2",
|
|
9
|
+
email: "u2@example.com",
|
|
10
|
+
name: "u2-name",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: "u3",
|
|
14
|
+
email: "u3@example.com",
|
|
15
|
+
name: "u3-name",
|
|
16
|
+
},
|
|
17
|
+
] as const;
|
|
18
|
+
|
|
19
|
+
export const books = [
|
|
20
|
+
{
|
|
21
|
+
__typename: "Book",
|
|
22
|
+
id: "p1",
|
|
23
|
+
sku: "sku-1",
|
|
24
|
+
title: "Book 1",
|
|
25
|
+
createdBy: "u1",
|
|
26
|
+
dimensions: {
|
|
27
|
+
size: "small",
|
|
28
|
+
weight: 0.5,
|
|
29
|
+
},
|
|
30
|
+
publisher: {
|
|
31
|
+
__typename: "Self",
|
|
32
|
+
email: users[0].email,
|
|
33
|
+
},
|
|
34
|
+
hidden: false,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
__typename: "Book",
|
|
38
|
+
id: "p3",
|
|
39
|
+
sku: "sku-3",
|
|
40
|
+
title: "Book 2",
|
|
41
|
+
createdBy: "u2",
|
|
42
|
+
dimensions: {
|
|
43
|
+
size: "small",
|
|
44
|
+
weight: 0.6,
|
|
45
|
+
},
|
|
46
|
+
publisher: {
|
|
47
|
+
__typename: "Agency",
|
|
48
|
+
id: "a1",
|
|
49
|
+
},
|
|
50
|
+
hidden: false,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
export const magazines = [
|
|
55
|
+
{
|
|
56
|
+
__typename: "Magazine",
|
|
57
|
+
id: "p2",
|
|
58
|
+
sku: "sku-2",
|
|
59
|
+
title: "Magazine 1",
|
|
60
|
+
createdBy: "u1",
|
|
61
|
+
dimensions: {
|
|
62
|
+
size: "small",
|
|
63
|
+
weight: 0.2,
|
|
64
|
+
},
|
|
65
|
+
publisher: {
|
|
66
|
+
__typename: "Agency",
|
|
67
|
+
id: "a1",
|
|
68
|
+
},
|
|
69
|
+
hidden: false,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
__typename: "Magazine",
|
|
73
|
+
id: "p4",
|
|
74
|
+
sku: "sku-4",
|
|
75
|
+
title: "Magazine 2",
|
|
76
|
+
createdBy: "u2",
|
|
77
|
+
dimensions: {
|
|
78
|
+
size: "small",
|
|
79
|
+
weight: 0.3,
|
|
80
|
+
},
|
|
81
|
+
publisher: {
|
|
82
|
+
__typename: "Self",
|
|
83
|
+
email: users[0].email,
|
|
84
|
+
},
|
|
85
|
+
hidden: true,
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
export const products = [...books, ...magazines] as const;
|
|
90
|
+
|
|
91
|
+
export const reviews = [
|
|
92
|
+
{
|
|
93
|
+
id: 1,
|
|
94
|
+
body: "review 1",
|
|
95
|
+
productId: "p1",
|
|
96
|
+
score: 3,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: 2,
|
|
100
|
+
body: "review 2",
|
|
101
|
+
productId: "p1",
|
|
102
|
+
score: 4,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: 3,
|
|
106
|
+
body: "review 3",
|
|
107
|
+
productId: "p2",
|
|
108
|
+
score: 5,
|
|
109
|
+
},
|
|
110
|
+
] as const;
|
|
111
|
+
|
|
112
|
+
export const agencies = [
|
|
113
|
+
{
|
|
114
|
+
id: "a1",
|
|
115
|
+
companyName: "Agency 1",
|
|
116
|
+
email: {
|
|
117
|
+
address: "a1@example.com",
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
] as const;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { serve } from "../../supergraph.js";
|
|
2
|
+
import inventorySubgraph from "./inventory.subgraph.js";
|
|
3
|
+
import booksSubgraph from "./books.subgraph.js";
|
|
4
|
+
import usersSubgraph from "./users.subgraph.js";
|
|
5
|
+
import productsSubgraph from "./products.subgraph.js";
|
|
6
|
+
import reviewsSubgraph from "./reviews.subgraph.js";
|
|
7
|
+
import magazinesSubgraph from "./magazines.subgraph.js";
|
|
8
|
+
import agencySubgraph from "./agency.subgraph.js";
|
|
9
|
+
import test from "./test.js";
|
|
10
|
+
|
|
11
|
+
export default serve(
|
|
12
|
+
"abstract-types",
|
|
13
|
+
[
|
|
14
|
+
agencySubgraph,
|
|
15
|
+
inventorySubgraph,
|
|
16
|
+
booksSubgraph,
|
|
17
|
+
usersSubgraph,
|
|
18
|
+
reviewsSubgraph,
|
|
19
|
+
productsSubgraph,
|
|
20
|
+
magazinesSubgraph,
|
|
21
|
+
],
|
|
22
|
+
test,
|
|
23
|
+
);
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { createSubgraph } from "../../subgraph.js";
|
|
2
|
+
import { books, magazines } from "./data.js";
|
|
3
|
+
|
|
4
|
+
export default createSubgraph("inventory", {
|
|
5
|
+
typeDefs: /* GraphQL */ `
|
|
6
|
+
extend schema
|
|
7
|
+
@link(
|
|
8
|
+
url: "https://specs.apollo.dev/federation/v2.3"
|
|
9
|
+
import: ["@key", "@shareable", "@external", "@requires"]
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
interface Product {
|
|
13
|
+
id: ID!
|
|
14
|
+
dimensions: ProductDimension
|
|
15
|
+
delivery(zip: String): DeliveryEstimates
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type Book implements Product @key(fields: "id") {
|
|
19
|
+
id: ID!
|
|
20
|
+
dimensions: ProductDimension @external
|
|
21
|
+
delivery(zip: String): DeliveryEstimates
|
|
22
|
+
@requires(fields: "dimensions { size weight }")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type Magazine implements Product @key(fields: "id") {
|
|
26
|
+
id: ID!
|
|
27
|
+
dimensions: ProductDimension @external
|
|
28
|
+
delivery(zip: String): DeliveryEstimates
|
|
29
|
+
@requires(fields: "dimensions { size weight }")
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type ProductDimension @shareable {
|
|
33
|
+
size: String
|
|
34
|
+
weight: Float
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type DeliveryEstimates {
|
|
38
|
+
estimatedDelivery: String
|
|
39
|
+
fastestDelivery: String
|
|
40
|
+
}
|
|
41
|
+
`,
|
|
42
|
+
resolvers: {
|
|
43
|
+
Book: {
|
|
44
|
+
__resolveReference(key: {
|
|
45
|
+
id: string;
|
|
46
|
+
dimensions?: {
|
|
47
|
+
size: string;
|
|
48
|
+
weight: number;
|
|
49
|
+
};
|
|
50
|
+
}) {
|
|
51
|
+
const book = books.find((book) => book.id === key.id);
|
|
52
|
+
|
|
53
|
+
if (!book) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
__typename: book.__typename,
|
|
59
|
+
id: book.id,
|
|
60
|
+
dimensions: key.dimensions,
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
delivery(
|
|
64
|
+
{ dimensions }: { dimensions?: { size: string; weight: number } },
|
|
65
|
+
{ zip }: { zip?: string },
|
|
66
|
+
) {
|
|
67
|
+
if (!zip) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!dimensions) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (dimensions.size === "small" && dimensions.weight < 1) {
|
|
76
|
+
return {
|
|
77
|
+
estimatedDelivery: "1 day",
|
|
78
|
+
fastestDelivery: "same day",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (dimensions.size === "large" && dimensions.weight >= 1) {
|
|
83
|
+
return {
|
|
84
|
+
estimatedDelivery: "3 days",
|
|
85
|
+
fastestDelivery: "2 days",
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return null;
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
Magazine: {
|
|
93
|
+
__resolveReference(key: {
|
|
94
|
+
id: string;
|
|
95
|
+
dimensions?: {
|
|
96
|
+
size: string;
|
|
97
|
+
weight: number;
|
|
98
|
+
};
|
|
99
|
+
}) {
|
|
100
|
+
const magazine = magazines.find((magazine) => magazine.id === key.id);
|
|
101
|
+
|
|
102
|
+
if (!magazine) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
__typename: magazine.__typename,
|
|
108
|
+
id: magazine.id,
|
|
109
|
+
dimensions: key.dimensions,
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
delivery(
|
|
113
|
+
{ dimensions }: { dimensions?: { size: string; weight: number } },
|
|
114
|
+
{ zip }: { zip?: string },
|
|
115
|
+
) {
|
|
116
|
+
if (!zip) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!dimensions) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (dimensions.size === "small" && dimensions.weight < 1) {
|
|
125
|
+
return {
|
|
126
|
+
estimatedDelivery: "1 day",
|
|
127
|
+
fastestDelivery: "same day",
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (dimensions.size === "large" && dimensions.weight >= 1) {
|
|
132
|
+
return {
|
|
133
|
+
estimatedDelivery: "3 days",
|
|
134
|
+
fastestDelivery: "2 days",
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return null;
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createSubgraph } from "../../subgraph.js";
|
|
2
|
+
import { magazines } from "./data.js";
|
|
3
|
+
|
|
4
|
+
export default createSubgraph("magazines", {
|
|
5
|
+
typeDefs: /* GraphQL */ `
|
|
6
|
+
schema
|
|
7
|
+
@link(
|
|
8
|
+
url: "https://specs.apollo.dev/federation/v2.3"
|
|
9
|
+
import: ["@key", "@shareable"]
|
|
10
|
+
) {
|
|
11
|
+
query: Query
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type Magazine @key(fields: "id") {
|
|
15
|
+
id: ID!
|
|
16
|
+
title: String
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type Query {
|
|
20
|
+
magazines: [Magazine]
|
|
21
|
+
}
|
|
22
|
+
`,
|
|
23
|
+
resolvers: {
|
|
24
|
+
Query: {
|
|
25
|
+
magazines() {
|
|
26
|
+
return magazines.map((magazine) => ({
|
|
27
|
+
__typename: magazine.__typename,
|
|
28
|
+
id: magazine.id,
|
|
29
|
+
title: magazine.title,
|
|
30
|
+
}));
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
Magazine: {
|
|
34
|
+
__resolveReference(key: { id: string }) {
|
|
35
|
+
const magazine = magazines.find((magazine) => magazine.id === key.id);
|
|
36
|
+
|
|
37
|
+
return magazine
|
|
38
|
+
? {
|
|
39
|
+
__typename: magazine.__typename,
|
|
40
|
+
id: magazine.id,
|
|
41
|
+
title: magazine.title,
|
|
42
|
+
}
|
|
43
|
+
: null;
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|