@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,104 @@
|
|
|
1
|
+
import { shouldPunishForPoorPlans } from "../../env.js";
|
|
2
|
+
import { createSubgraph } from "../../subgraph.js";
|
|
3
|
+
import { categories, products } from "./data.js";
|
|
4
|
+
|
|
5
|
+
export default createSubgraph("category", {
|
|
6
|
+
typeDefs: /* GraphQL */ `
|
|
7
|
+
extend schema
|
|
8
|
+
@link(
|
|
9
|
+
url: "https://specs.apollo.dev/federation/v2.3"
|
|
10
|
+
import: ["@key", "@shareable", "@external", "@provides"]
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
type Query {
|
|
14
|
+
products: [Product]
|
|
15
|
+
@shareable
|
|
16
|
+
@provides(fields: "categories { id name subCategories { id name } }")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type Product @key(fields: "id") {
|
|
20
|
+
id: ID!
|
|
21
|
+
categories: [Category] @external
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type Category @key(fields: "id") {
|
|
25
|
+
id: ID!
|
|
26
|
+
"""
|
|
27
|
+
This field is provided by Query.products
|
|
28
|
+
and we deliberately don't resolve it.
|
|
29
|
+
The test suite is about checking if @provides is used correctly.
|
|
30
|
+
"""
|
|
31
|
+
name: String
|
|
32
|
+
subCategories: [Category] @external
|
|
33
|
+
}
|
|
34
|
+
`,
|
|
35
|
+
resolvers: {
|
|
36
|
+
Query: {
|
|
37
|
+
products() {
|
|
38
|
+
return products.map((p) => ({
|
|
39
|
+
id: p.id,
|
|
40
|
+
categories: p.categories.map((catId) => {
|
|
41
|
+
const cat = categories.find((c) => c.id === catId);
|
|
42
|
+
|
|
43
|
+
if (!cat) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
id: cat.id,
|
|
49
|
+
name: cat.name,
|
|
50
|
+
subCategories: cat.subCategories.map((subCatId) => {
|
|
51
|
+
const subCat = categories.find((c) => c.id === subCatId);
|
|
52
|
+
|
|
53
|
+
if (!subCat) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
id: subCat.id,
|
|
59
|
+
name: subCat.name,
|
|
60
|
+
};
|
|
61
|
+
}),
|
|
62
|
+
};
|
|
63
|
+
}),
|
|
64
|
+
}));
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
Product: {
|
|
68
|
+
__resolveReference(key: { id: string }, context: any) {
|
|
69
|
+
if (shouldPunishForPoorPlans(context)) {
|
|
70
|
+
throw new Error("You should be using the categories subgraph!");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const product = products.find((p) => p.id === key.id);
|
|
74
|
+
|
|
75
|
+
if (!product) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
id: product.id,
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
Category: {
|
|
85
|
+
__resolveReference(key: { id: string }, context: any) {
|
|
86
|
+
if (shouldPunishForPoorPlans(context)) {
|
|
87
|
+
throw new Error("You should be using the categories subgraph!");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const cat = categories.find((c) => c.id === key.id);
|
|
91
|
+
|
|
92
|
+
if (!cat) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
id: cat.id,
|
|
98
|
+
// We explicitly don't resolve `name` here
|
|
99
|
+
// name: cat.name,
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const products = [
|
|
2
|
+
{
|
|
3
|
+
id: "p1",
|
|
4
|
+
categories: ["c1", "c2"],
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
id: "p2",
|
|
8
|
+
categories: ["c3", "c2"],
|
|
9
|
+
},
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export const categories = [
|
|
13
|
+
{
|
|
14
|
+
id: "c1",
|
|
15
|
+
name: "Category 1",
|
|
16
|
+
subCategories: ["c2"],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "c2",
|
|
20
|
+
name: "Category 2",
|
|
21
|
+
subCategories: ["c3"],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "c3",
|
|
25
|
+
name: "Category 3",
|
|
26
|
+
subCategories: ["c1"],
|
|
27
|
+
},
|
|
28
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { serve } from "../../supergraph.js";
|
|
2
|
+
import allProducts from "./all-products.subgraph.js";
|
|
3
|
+
import category from "./category.subgraph.js";
|
|
4
|
+
import subcategories from "./subcategories.subgraph.js";
|
|
5
|
+
import test from "./test.js";
|
|
6
|
+
|
|
7
|
+
export default serve(
|
|
8
|
+
"nested-provides",
|
|
9
|
+
[allProducts, category, subcategories],
|
|
10
|
+
test,
|
|
11
|
+
);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { shouldPunishForPoorPlans } from "../../env.js";
|
|
2
|
+
import { createSubgraph } from "../../subgraph.js";
|
|
3
|
+
import { categories, products } from "./data.js";
|
|
4
|
+
|
|
5
|
+
export default createSubgraph("subcategories", {
|
|
6
|
+
typeDefs: /* GraphQL */ `
|
|
7
|
+
extend schema
|
|
8
|
+
@link(
|
|
9
|
+
url: "https://specs.apollo.dev/federation/v2.3"
|
|
10
|
+
import: ["@key", "@shareable"]
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
type Product @key(fields: "id") {
|
|
14
|
+
id: ID!
|
|
15
|
+
categories: [Category] @shareable
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type Category @key(fields: "id") {
|
|
19
|
+
id: ID!
|
|
20
|
+
subCategories: [Category] @shareable
|
|
21
|
+
}
|
|
22
|
+
`,
|
|
23
|
+
resolvers: {
|
|
24
|
+
Product: {
|
|
25
|
+
__resolveReference(key: { id: string }, context: any) {
|
|
26
|
+
if (shouldPunishForPoorPlans(context)) {
|
|
27
|
+
throw new Error("You should be using the categories subgraph!");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const product = products.find((p) => p.id === key.id);
|
|
31
|
+
|
|
32
|
+
if (!product) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
id: product.id,
|
|
38
|
+
categories: product.categories,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
categories(product: { categories: string[] }, _a: unknown, context: any) {
|
|
42
|
+
if (shouldPunishForPoorPlans(context)) {
|
|
43
|
+
throw new Error("You should be using the categories subgraph!");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return product.categories.map((catId) => {
|
|
47
|
+
const cat = categories.find((c) => c.id === catId);
|
|
48
|
+
|
|
49
|
+
if (!cat) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
id: cat.id,
|
|
55
|
+
subCategories: cat.subCategories,
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
Category: {
|
|
61
|
+
__resolveReference(key: { id: string }) {
|
|
62
|
+
const cat = categories.find((c) => c.id === key.id);
|
|
63
|
+
|
|
64
|
+
if (!cat) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
id: cat.id,
|
|
70
|
+
subCategories: cat.subCategories,
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
subCategories(category: { subCategories: string[] }) {
|
|
74
|
+
return category.subCategories.map((catId) => {
|
|
75
|
+
const cat = categories.find((c) => c.id === catId);
|
|
76
|
+
|
|
77
|
+
if (!cat) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
id: cat.id,
|
|
83
|
+
subCategories: cat.subCategories,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { createTest } from "../../testkit.js";
|
|
2
|
+
|
|
3
|
+
export default [
|
|
4
|
+
createTest(
|
|
5
|
+
/* GraphQL */ `
|
|
6
|
+
query {
|
|
7
|
+
products {
|
|
8
|
+
id
|
|
9
|
+
categories {
|
|
10
|
+
id
|
|
11
|
+
name
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`,
|
|
16
|
+
{
|
|
17
|
+
data: {
|
|
18
|
+
products: [
|
|
19
|
+
{
|
|
20
|
+
id: "p1",
|
|
21
|
+
categories: [
|
|
22
|
+
{
|
|
23
|
+
id: "c1",
|
|
24
|
+
name: "Category 1",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "c2",
|
|
28
|
+
name: "Category 2",
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "p2",
|
|
34
|
+
categories: [
|
|
35
|
+
{
|
|
36
|
+
id: "c3",
|
|
37
|
+
name: "Category 3",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "c2",
|
|
41
|
+
name: "Category 2",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
),
|
|
49
|
+
createTest(
|
|
50
|
+
/* GraphQL */ `
|
|
51
|
+
query {
|
|
52
|
+
products {
|
|
53
|
+
id
|
|
54
|
+
categories {
|
|
55
|
+
id
|
|
56
|
+
name
|
|
57
|
+
subCategories {
|
|
58
|
+
id
|
|
59
|
+
name
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
`,
|
|
65
|
+
{
|
|
66
|
+
data: {
|
|
67
|
+
products: [
|
|
68
|
+
{
|
|
69
|
+
id: "p1",
|
|
70
|
+
categories: [
|
|
71
|
+
{
|
|
72
|
+
id: "c1",
|
|
73
|
+
name: "Category 1",
|
|
74
|
+
subCategories: [
|
|
75
|
+
{
|
|
76
|
+
id: "c2",
|
|
77
|
+
name: "Category 2",
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: "c2",
|
|
83
|
+
name: "Category 2",
|
|
84
|
+
subCategories: [
|
|
85
|
+
{
|
|
86
|
+
id: "c3",
|
|
87
|
+
name: "Category 3",
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: "p2",
|
|
95
|
+
categories: [
|
|
96
|
+
{
|
|
97
|
+
id: "c3",
|
|
98
|
+
name: "Category 3",
|
|
99
|
+
subCategories: [
|
|
100
|
+
{
|
|
101
|
+
id: "c1",
|
|
102
|
+
name: "Category 1",
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: "c2",
|
|
108
|
+
name: "Category 2",
|
|
109
|
+
subCategories: [
|
|
110
|
+
{
|
|
111
|
+
id: "c3",
|
|
112
|
+
name: "Category 3",
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
),
|
|
122
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const products = [
|
|
2
|
+
{
|
|
3
|
+
id: "p-1",
|
|
4
|
+
name: "Product 1",
|
|
5
|
+
price: 10.0,
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
id: "p-2",
|
|
9
|
+
name: "Product 2",
|
|
10
|
+
price: 20.0,
|
|
11
|
+
},
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
export const categories = [
|
|
15
|
+
{
|
|
16
|
+
id: "pc-1",
|
|
17
|
+
name: "Category 1",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: "c-2",
|
|
21
|
+
name: "Category 2",
|
|
22
|
+
},
|
|
23
|
+
];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createSubgraph } from "../../subgraph.js";
|
|
2
|
+
import { categories, products } from "./data.js";
|
|
3
|
+
|
|
4
|
+
export default createSubgraph("node-two", {
|
|
5
|
+
typeDefs: /* GraphQL */ `
|
|
6
|
+
extend schema
|
|
7
|
+
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key"])
|
|
8
|
+
|
|
9
|
+
interface Node {
|
|
10
|
+
id: ID!
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Product implements Node @key(fields: "id") {
|
|
14
|
+
id: ID!
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type Category implements Node @key(fields: "id") {
|
|
18
|
+
id: ID!
|
|
19
|
+
}
|
|
20
|
+
`,
|
|
21
|
+
resolvers: {
|
|
22
|
+
Product: {
|
|
23
|
+
__resolveReference(key: { id: string }) {
|
|
24
|
+
const product = products.find((p) => p.id === key.id);
|
|
25
|
+
|
|
26
|
+
if (!product) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
id: product.id,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
Category: {
|
|
36
|
+
__resolveReference(key: { id: string }) {
|
|
37
|
+
const cat = categories.find((c) => c.id === key.id);
|
|
38
|
+
|
|
39
|
+
if (!cat) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
id: cat.id,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createSubgraph } from "../../subgraph.js";
|
|
2
|
+
import { categories, products } from "./data.js";
|
|
3
|
+
|
|
4
|
+
export default createSubgraph("node", {
|
|
5
|
+
typeDefs: /* GraphQL */ `
|
|
6
|
+
extend schema
|
|
7
|
+
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key"])
|
|
8
|
+
|
|
9
|
+
type Query {
|
|
10
|
+
productNode: Node
|
|
11
|
+
categoryNode: Node
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface Node {
|
|
15
|
+
id: ID!
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type Product implements Node @key(fields: "id") {
|
|
19
|
+
id: ID!
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type Category implements Node @key(fields: "id") {
|
|
23
|
+
id: ID!
|
|
24
|
+
}
|
|
25
|
+
`,
|
|
26
|
+
resolvers: {
|
|
27
|
+
Query: {
|
|
28
|
+
productNode() {
|
|
29
|
+
return {
|
|
30
|
+
__typename: "Product",
|
|
31
|
+
id: products[0].id,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
categoryNode() {
|
|
35
|
+
return {
|
|
36
|
+
__typename: "Category",
|
|
37
|
+
id: categories[0].id,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
Product: {
|
|
42
|
+
__resolveReference(key: { id: string }) {
|
|
43
|
+
const product = products.find((p) => p.id === key.id);
|
|
44
|
+
|
|
45
|
+
if (!product) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
id: product.id,
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
Category: {
|
|
55
|
+
__resolveReference(key: { id: string }) {
|
|
56
|
+
const cat = categories.find((c) => c.id === key.id);
|
|
57
|
+
|
|
58
|
+
if (!cat) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
id: cat.id,
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createTest } from "../../testkit.js";
|
|
2
|
+
|
|
3
|
+
export default [
|
|
4
|
+
createTest(
|
|
5
|
+
/* GraphQL */ `
|
|
6
|
+
{
|
|
7
|
+
productNode {
|
|
8
|
+
... on Product {
|
|
9
|
+
id
|
|
10
|
+
name
|
|
11
|
+
__typename
|
|
12
|
+
price
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`,
|
|
17
|
+
{
|
|
18
|
+
data: {
|
|
19
|
+
productNode: {
|
|
20
|
+
id: "p-1",
|
|
21
|
+
name: "Product 1",
|
|
22
|
+
__typename: "Product",
|
|
23
|
+
price: 10,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
),
|
|
28
|
+
];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createSubgraph } from "../../subgraph.js";
|
|
2
|
+
import { categories, products } from "./data.js";
|
|
3
|
+
|
|
4
|
+
export default createSubgraph("types", {
|
|
5
|
+
typeDefs: /* GraphQL */ `
|
|
6
|
+
extend schema
|
|
7
|
+
@link(
|
|
8
|
+
url: "https://specs.apollo.dev/federation/v2.3"
|
|
9
|
+
import: ["@key", "@shareable"]
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
interface Node {
|
|
13
|
+
id: ID!
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type Product implements Node @key(fields: "id") @shareable {
|
|
17
|
+
id: ID!
|
|
18
|
+
name: String!
|
|
19
|
+
price: Float!
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type Category implements Node @key(fields: "id") {
|
|
23
|
+
id: ID!
|
|
24
|
+
name: String!
|
|
25
|
+
}
|
|
26
|
+
`,
|
|
27
|
+
resolvers: {
|
|
28
|
+
Product: {
|
|
29
|
+
__resolveReference(key: { id: string }) {
|
|
30
|
+
const product = products.find((p) => p.id === key.id);
|
|
31
|
+
|
|
32
|
+
if (!product) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
id: product.id,
|
|
38
|
+
name: product.name,
|
|
39
|
+
price: product.price,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
Category: {
|
|
44
|
+
__resolveReference(key: { id: string }) {
|
|
45
|
+
const cat = categories.find((c) => c.id === key.id);
|
|
46
|
+
|
|
47
|
+
if (!cat) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
id: cat.id,
|
|
53
|
+
name: cat.name,
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createSubgraph } from "../../subgraph.js";
|
|
2
|
+
import { products } from "./data.js";
|
|
3
|
+
|
|
4
|
+
export default createSubgraph("a", {
|
|
5
|
+
typeDefs: /* GraphQL */ `
|
|
6
|
+
extend schema
|
|
7
|
+
@link(
|
|
8
|
+
url: "https://specs.apollo.dev/federation/v2.3"
|
|
9
|
+
import: ["@key", "@interfaceObject"]
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
interface Node @key(fields: "id") {
|
|
13
|
+
id: ID!
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type Product @key(fields: "id", resolvable: false) @interfaceObject {
|
|
17
|
+
id: ID!
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type Query {
|
|
21
|
+
a: Node
|
|
22
|
+
product: Product!
|
|
23
|
+
}
|
|
24
|
+
`,
|
|
25
|
+
resolvers: {
|
|
26
|
+
Query: {
|
|
27
|
+
a() {
|
|
28
|
+
return { __typename: "Node", id: "n1" };
|
|
29
|
+
},
|
|
30
|
+
product() {
|
|
31
|
+
return { __typename: "Product", id: products[0].id };
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
Node: {
|
|
35
|
+
__resolveReference() {
|
|
36
|
+
throw new Error("Not resolvable as it is an interface object");
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createSubgraph } from "../../subgraph.js";
|
|
2
|
+
import { products } from "./data.js";
|
|
3
|
+
|
|
4
|
+
export default createSubgraph("b", {
|
|
5
|
+
typeDefs: /* GraphQL */ `
|
|
6
|
+
extend schema
|
|
7
|
+
@link(
|
|
8
|
+
url: "https://specs.apollo.dev/federation/v2.3"
|
|
9
|
+
import: ["@key", "@interfaceObject"]
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
type Node @key(fields: "id", resolvable: false) @interfaceObject {
|
|
13
|
+
id: ID!
|
|
14
|
+
field: String
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface Product @key(fields: "id") {
|
|
18
|
+
id: ID!
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type Bread implements Product @key(fields: "id") {
|
|
22
|
+
id: ID!
|
|
23
|
+
name: String!
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type Query {
|
|
27
|
+
b: Node
|
|
28
|
+
}
|
|
29
|
+
`,
|
|
30
|
+
resolvers: {
|
|
31
|
+
Query: {
|
|
32
|
+
b() {
|
|
33
|
+
return { __typename: "Node", id: "n1" };
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
Node: {
|
|
37
|
+
__resolveReference() {
|
|
38
|
+
throw new Error("Not resolvable");
|
|
39
|
+
},
|
|
40
|
+
field() {
|
|
41
|
+
return "foo";
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
Product: {
|
|
45
|
+
__resolveReference(key: { id: string }) {
|
|
46
|
+
return products.find((p) => p.id === key.id);
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
Bread: {
|
|
50
|
+
__resolveReference(key: { id: string }) {
|
|
51
|
+
return products.find((p) => p.id === key.id);
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|