@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,79 @@
|
|
|
1
|
+
import { createSubgraph } from "../../subgraph.js";
|
|
2
|
+
import { media } from "./data.js";
|
|
3
|
+
|
|
4
|
+
const movie = {
|
|
5
|
+
__typename: "Movie",
|
|
6
|
+
id: "m3",
|
|
7
|
+
title: "A Movie Title",
|
|
8
|
+
bTitle: "B Movie Title",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default createSubgraph("b", {
|
|
12
|
+
typeDefs: /* GraphQL */ `
|
|
13
|
+
extend schema
|
|
14
|
+
@link(
|
|
15
|
+
url: "https://specs.apollo.dev/federation/v2.3"
|
|
16
|
+
import: ["@shareable", "@key"]
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
type Query {
|
|
20
|
+
media: Media @shareable
|
|
21
|
+
bMedia: Media @shareable
|
|
22
|
+
book: Media @shareable
|
|
23
|
+
viewer: Viewer @shareable
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
union Media = Book | Movie
|
|
27
|
+
union ViewerMedia = Book | Movie
|
|
28
|
+
|
|
29
|
+
type Movie @key(fields: "id") {
|
|
30
|
+
id: ID!
|
|
31
|
+
title: String! @shareable
|
|
32
|
+
bTitle: String!
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type Book @key(fields: "id") {
|
|
36
|
+
id: ID!
|
|
37
|
+
title: String! @shareable
|
|
38
|
+
bTitle: String!
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type Viewer {
|
|
42
|
+
media: ViewerMedia @shareable
|
|
43
|
+
bMedia: ViewerMedia
|
|
44
|
+
book: ViewerMedia @shareable
|
|
45
|
+
}
|
|
46
|
+
`,
|
|
47
|
+
resolvers: {
|
|
48
|
+
Query: {
|
|
49
|
+
media: () => media,
|
|
50
|
+
bMedia: () => media,
|
|
51
|
+
book: () => media,
|
|
52
|
+
viewer: () => {
|
|
53
|
+
return {
|
|
54
|
+
media,
|
|
55
|
+
bMedia: movie,
|
|
56
|
+
book: media,
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
Book: {
|
|
61
|
+
__resolveReference(key: { id: string }) {
|
|
62
|
+
if (key.id !== media.id) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return media;
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
Movie: {
|
|
70
|
+
__resolveReference(key: { id: string }) {
|
|
71
|
+
if (key.id !== movie.id) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return movie;
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
});
|
|
@@ -1,180 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import 'graphql';
|
|
4
|
-
import 'fets';
|
|
5
|
-
import '@apollo/subgraph';
|
|
6
|
-
import 'graphql-yoga';
|
|
1
|
+
import { createTest } from "../../testkit.js";
|
|
2
|
+
import { media } from "./data.js";
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
__typename: "Book",
|
|
10
|
-
id: "b1",
|
|
11
|
-
title: "The Lord of the Rings",
|
|
12
|
-
aTitle: "A: The Lord of the Rings",
|
|
13
|
-
bTitle: "B: The Lord of the Rings"
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const song = {
|
|
17
|
-
__typename: "Song",
|
|
18
|
-
id: "s2",
|
|
19
|
-
title: "Song Title",
|
|
20
|
-
aTitle: "A: Song Title"
|
|
21
|
-
};
|
|
22
|
-
var a = createSubgraph("a", {
|
|
23
|
-
typeDefs: (
|
|
24
|
-
/* GraphQL */
|
|
25
|
-
`
|
|
26
|
-
extend schema
|
|
27
|
-
@link(
|
|
28
|
-
url: "https://specs.apollo.dev/federation/v2.3"
|
|
29
|
-
import: ["@shareable", "@key"]
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
union Media = Book | Song
|
|
33
|
-
union ViewerMedia = Book | Song
|
|
34
|
-
|
|
35
|
-
type Book @key(fields: "id") {
|
|
36
|
-
id: ID!
|
|
37
|
-
title: String! @shareable
|
|
38
|
-
aTitle: String!
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
type Song @key(fields: "id") {
|
|
42
|
-
id: ID!
|
|
43
|
-
title: String! @shareable
|
|
44
|
-
aTitle: String!
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
type Query {
|
|
48
|
-
media: Media @shareable
|
|
49
|
-
aMedia: Media @shareable
|
|
50
|
-
book: Book @shareable
|
|
51
|
-
song: Media @shareable
|
|
52
|
-
viewer: Viewer @shareable
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
type Viewer {
|
|
56
|
-
media: ViewerMedia @shareable
|
|
57
|
-
aMedia: ViewerMedia
|
|
58
|
-
book: Book @shareable
|
|
59
|
-
song: ViewerMedia @shareable
|
|
60
|
-
}
|
|
61
|
-
`
|
|
62
|
-
),
|
|
63
|
-
resolvers: {
|
|
64
|
-
Query: {
|
|
65
|
-
media: () => media,
|
|
66
|
-
aMedia: () => media,
|
|
67
|
-
book: () => media,
|
|
68
|
-
song: () => song,
|
|
69
|
-
viewer: () => {
|
|
70
|
-
return {
|
|
71
|
-
media,
|
|
72
|
-
aMedia: media,
|
|
73
|
-
book: media,
|
|
74
|
-
song
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
Book: {
|
|
79
|
-
__resolveReference(key) {
|
|
80
|
-
if (key.id !== media.id) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
return media;
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
Song: {
|
|
87
|
-
__resolveReference(key) {
|
|
88
|
-
if (key.id !== song.id) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
return song;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const movie = {
|
|
98
|
-
__typename: "Movie",
|
|
99
|
-
id: "m3",
|
|
100
|
-
title: "A Movie Title",
|
|
101
|
-
bTitle: "B Movie Title"
|
|
102
|
-
};
|
|
103
|
-
var b = createSubgraph("b", {
|
|
104
|
-
typeDefs: (
|
|
105
|
-
/* GraphQL */
|
|
106
|
-
`
|
|
107
|
-
extend schema
|
|
108
|
-
@link(
|
|
109
|
-
url: "https://specs.apollo.dev/federation/v2.3"
|
|
110
|
-
import: ["@shareable", "@key"]
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
type Query {
|
|
114
|
-
media: Media @shareable
|
|
115
|
-
bMedia: Media @shareable
|
|
116
|
-
book: Media @shareable
|
|
117
|
-
viewer: Viewer @shareable
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
union Media = Book | Movie
|
|
121
|
-
union ViewerMedia = Book | Movie
|
|
122
|
-
|
|
123
|
-
type Movie @key(fields: "id") {
|
|
124
|
-
id: ID!
|
|
125
|
-
title: String! @shareable
|
|
126
|
-
bTitle: String!
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
type Book @key(fields: "id") {
|
|
130
|
-
id: ID!
|
|
131
|
-
title: String! @shareable
|
|
132
|
-
bTitle: String!
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
type Viewer {
|
|
136
|
-
media: ViewerMedia @shareable
|
|
137
|
-
bMedia: ViewerMedia
|
|
138
|
-
book: ViewerMedia @shareable
|
|
139
|
-
}
|
|
140
|
-
`
|
|
141
|
-
),
|
|
142
|
-
resolvers: {
|
|
143
|
-
Query: {
|
|
144
|
-
media: () => media,
|
|
145
|
-
bMedia: () => media,
|
|
146
|
-
book: () => media,
|
|
147
|
-
viewer: () => {
|
|
148
|
-
return {
|
|
149
|
-
media,
|
|
150
|
-
bMedia: movie,
|
|
151
|
-
book: media
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
Book: {
|
|
156
|
-
__resolveReference(key) {
|
|
157
|
-
if (key.id !== media.id) {
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
return media;
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
Movie: {
|
|
164
|
-
__resolveReference(key) {
|
|
165
|
-
if (key.id !== movie.id) {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
return movie;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
var test = [
|
|
4
|
+
export default [
|
|
175
5
|
createTest(
|
|
176
|
-
/* GraphQL */
|
|
177
|
-
`
|
|
6
|
+
/* GraphQL */ `
|
|
178
7
|
query {
|
|
179
8
|
media {
|
|
180
9
|
... on Movie {
|
|
@@ -185,13 +14,12 @@ var test = [
|
|
|
185
14
|
`,
|
|
186
15
|
{
|
|
187
16
|
data: {
|
|
188
|
-
media: {}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
17
|
+
media: {},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
191
20
|
),
|
|
192
21
|
createTest(
|
|
193
|
-
/* GraphQL */
|
|
194
|
-
`
|
|
22
|
+
/* GraphQL */ `
|
|
195
23
|
query {
|
|
196
24
|
media {
|
|
197
25
|
... on Book {
|
|
@@ -203,14 +31,13 @@ var test = [
|
|
|
203
31
|
{
|
|
204
32
|
data: {
|
|
205
33
|
media: {
|
|
206
|
-
title: media.title
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
34
|
+
title: media.title,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
210
38
|
),
|
|
211
39
|
createTest(
|
|
212
|
-
/* GraphQL */
|
|
213
|
-
`
|
|
40
|
+
/* GraphQL */ `
|
|
214
41
|
query {
|
|
215
42
|
media {
|
|
216
43
|
... on Book {
|
|
@@ -225,14 +52,13 @@ var test = [
|
|
|
225
52
|
{
|
|
226
53
|
data: {
|
|
227
54
|
media: {
|
|
228
|
-
title: media.title
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
55
|
+
title: media.title,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
232
59
|
),
|
|
233
60
|
createTest(
|
|
234
|
-
/* GraphQL */
|
|
235
|
-
`
|
|
61
|
+
/* GraphQL */ `
|
|
236
62
|
query {
|
|
237
63
|
viewer {
|
|
238
64
|
media {
|
|
@@ -279,23 +105,22 @@ var test = [
|
|
|
279
105
|
viewer: {
|
|
280
106
|
media: {
|
|
281
107
|
__typename: "Book",
|
|
282
|
-
title: "The Lord of the Rings"
|
|
108
|
+
title: "The Lord of the Rings",
|
|
283
109
|
},
|
|
284
110
|
book: {
|
|
285
111
|
__typename: "Book",
|
|
286
|
-
title: "The Lord of the Rings"
|
|
112
|
+
title: "The Lord of the Rings",
|
|
287
113
|
},
|
|
288
114
|
song: {
|
|
289
115
|
__typename: "Song",
|
|
290
|
-
title: "Song Title"
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
116
|
+
title: "Song Title",
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
295
121
|
),
|
|
296
122
|
createTest(
|
|
297
|
-
/* GraphQL */
|
|
298
|
-
`
|
|
123
|
+
/* GraphQL */ `
|
|
299
124
|
query {
|
|
300
125
|
viewer {
|
|
301
126
|
media {
|
|
@@ -309,14 +134,13 @@ var test = [
|
|
|
309
134
|
{
|
|
310
135
|
data: {
|
|
311
136
|
viewer: {
|
|
312
|
-
media: {}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
137
|
+
media: {},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
316
141
|
),
|
|
317
142
|
createTest(
|
|
318
|
-
/* GraphQL */
|
|
319
|
-
`
|
|
143
|
+
/* GraphQL */ `
|
|
320
144
|
query {
|
|
321
145
|
viewer {
|
|
322
146
|
media {
|
|
@@ -331,15 +155,14 @@ var test = [
|
|
|
331
155
|
data: {
|
|
332
156
|
viewer: {
|
|
333
157
|
media: {
|
|
334
|
-
title: media.title
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
158
|
+
title: media.title,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
339
163
|
),
|
|
340
164
|
createTest(
|
|
341
|
-
/* GraphQL */
|
|
342
|
-
`
|
|
165
|
+
/* GraphQL */ `
|
|
343
166
|
query {
|
|
344
167
|
viewer {
|
|
345
168
|
media {
|
|
@@ -357,15 +180,14 @@ var test = [
|
|
|
357
180
|
data: {
|
|
358
181
|
viewer: {
|
|
359
182
|
media: {
|
|
360
|
-
title: media.title
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
183
|
+
title: media.title,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
365
188
|
),
|
|
366
189
|
createTest(
|
|
367
|
-
/* GraphQL */
|
|
368
|
-
`
|
|
190
|
+
/* GraphQL */ `
|
|
369
191
|
query {
|
|
370
192
|
viewer {
|
|
371
193
|
media {
|
|
@@ -412,24 +234,23 @@ var test = [
|
|
|
412
234
|
viewer: {
|
|
413
235
|
media: {
|
|
414
236
|
__typename: "Book",
|
|
415
|
-
title: "The Lord of the Rings"
|
|
237
|
+
title: "The Lord of the Rings",
|
|
416
238
|
},
|
|
417
239
|
book: {
|
|
418
240
|
__typename: "Book",
|
|
419
|
-
title: "The Lord of the Rings"
|
|
241
|
+
title: "The Lord of the Rings",
|
|
420
242
|
},
|
|
421
243
|
song: {
|
|
422
244
|
__typename: "Song",
|
|
423
|
-
title: "Song Title"
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
245
|
+
title: "Song Title",
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
},
|
|
428
250
|
),
|
|
429
251
|
// this part involves entity calls
|
|
430
252
|
createTest(
|
|
431
|
-
/* GraphQL */
|
|
432
|
-
`
|
|
253
|
+
/* GraphQL */ `
|
|
433
254
|
query {
|
|
434
255
|
aMedia {
|
|
435
256
|
... on Movie {
|
|
@@ -441,13 +262,12 @@ var test = [
|
|
|
441
262
|
`,
|
|
442
263
|
{
|
|
443
264
|
data: {
|
|
444
|
-
aMedia: {}
|
|
445
|
-
}
|
|
446
|
-
}
|
|
265
|
+
aMedia: {},
|
|
266
|
+
},
|
|
267
|
+
},
|
|
447
268
|
),
|
|
448
269
|
createTest(
|
|
449
|
-
/* GraphQL */
|
|
450
|
-
`
|
|
270
|
+
/* GraphQL */ `
|
|
451
271
|
query {
|
|
452
272
|
aMedia {
|
|
453
273
|
... on Book {
|
|
@@ -463,14 +283,13 @@ var test = [
|
|
|
463
283
|
aMedia: {
|
|
464
284
|
title: media.title,
|
|
465
285
|
aTitle: media.aTitle,
|
|
466
|
-
bTitle: media.bTitle
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
286
|
+
bTitle: media.bTitle,
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
},
|
|
470
290
|
),
|
|
471
291
|
createTest(
|
|
472
|
-
/* GraphQL */
|
|
473
|
-
`
|
|
292
|
+
/* GraphQL */ `
|
|
474
293
|
query {
|
|
475
294
|
viewer {
|
|
476
295
|
media {
|
|
@@ -531,26 +350,25 @@ var test = [
|
|
|
531
350
|
__typename: "Book",
|
|
532
351
|
title: "The Lord of the Rings",
|
|
533
352
|
aTitle: "A: The Lord of the Rings",
|
|
534
|
-
bTitle: "B: The Lord of the Rings"
|
|
353
|
+
bTitle: "B: The Lord of the Rings",
|
|
535
354
|
},
|
|
536
355
|
book: {
|
|
537
356
|
__typename: "Book",
|
|
538
357
|
title: "The Lord of the Rings",
|
|
539
358
|
aTitle: "A: The Lord of the Rings",
|
|
540
|
-
bTitle: "B: The Lord of the Rings"
|
|
359
|
+
bTitle: "B: The Lord of the Rings",
|
|
541
360
|
},
|
|
542
361
|
song: {
|
|
543
362
|
__typename: "Song",
|
|
544
363
|
title: "Song Title",
|
|
545
|
-
aTitle: "A: Song Title"
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
}
|
|
364
|
+
aTitle: "A: Song Title",
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
},
|
|
550
369
|
),
|
|
551
370
|
createTest(
|
|
552
|
-
/* GraphQL */
|
|
553
|
-
`
|
|
371
|
+
/* GraphQL */ `
|
|
554
372
|
query {
|
|
555
373
|
viewer {
|
|
556
374
|
aMedia {
|
|
@@ -574,14 +392,10 @@ var test = [
|
|
|
574
392
|
aMedia: {},
|
|
575
393
|
bMedia: {
|
|
576
394
|
title: "A Movie Title",
|
|
577
|
-
bTitle: "B Movie Title"
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
)
|
|
395
|
+
bTitle: "B Movie Title",
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
),
|
|
583
401
|
];
|
|
584
|
-
|
|
585
|
-
var index = serve("union-intersection", [a, b], test);
|
|
586
|
-
|
|
587
|
-
export { index as default };
|
package/src/test.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ExecutionResult } from "graphql";
|
|
2
|
+
import type { createTest } from "./testkit.js";
|
|
3
|
+
import { diff } from "jest-diff";
|
|
4
|
+
import { it, describe } from "node:test";
|
|
5
|
+
import { deepStrictEqual } from "node:assert";
|
|
6
|
+
|
|
7
|
+
async function fetchTests(endpoint: string) {
|
|
8
|
+
const response = await fetch(endpoint, {
|
|
9
|
+
method: "GET",
|
|
10
|
+
headers: {
|
|
11
|
+
Accept: "application/json",
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (response.status !== 200) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
`Failed to fetch tests ${response.status} ${response.statusText}`,
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const result = await response.json();
|
|
22
|
+
|
|
23
|
+
return result as Array<ReturnType<typeof createTest>>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const TEST_SUITE = process.env.TEST_SUITE;
|
|
27
|
+
const TESTS_ENDPOINT = process.env.TESTS_ENDPOINT;
|
|
28
|
+
const GRAPHQL_ENDPOINT = process.env.GRAPHQL_ENDPOINT;
|
|
29
|
+
|
|
30
|
+
assert(TESTS_ENDPOINT, "TESTS_ENDPOINT is required");
|
|
31
|
+
assert(GRAPHQL_ENDPOINT, "GRAPHQL_ENDPOINT is required");
|
|
32
|
+
|
|
33
|
+
console.log(`Using gateway at ${GRAPHQL_ENDPOINT}`);
|
|
34
|
+
console.log(`Fetching tests from ${TESTS_ENDPOINT}`);
|
|
35
|
+
console.log(`\n`);
|
|
36
|
+
|
|
37
|
+
const tests = await fetchTests(TESTS_ENDPOINT);
|
|
38
|
+
|
|
39
|
+
let index = 0;
|
|
40
|
+
describe(TEST_SUITE, () => {
|
|
41
|
+
for (const { query, expected: expectedResult } of tests) {
|
|
42
|
+
it(`${TEST_SUITE}_${index++}`, async () => {
|
|
43
|
+
const response = await graphql(GRAPHQL_ENDPOINT, query);
|
|
44
|
+
|
|
45
|
+
const errorsOptional = typeof expectedResult.errors !== "boolean";
|
|
46
|
+
|
|
47
|
+
const received = {
|
|
48
|
+
data: response.data ?? null,
|
|
49
|
+
errors: errorsOptional ? null : response.errors?.length ? true : false,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const expected = {
|
|
53
|
+
data: expectedResult.data ?? null,
|
|
54
|
+
errors: errorsOptional ? null : (expectedResult.errors ?? false),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
let retryCount = 0;
|
|
58
|
+
const maxRetries = 2;
|
|
59
|
+
let testPassed = false;
|
|
60
|
+
|
|
61
|
+
while (retryCount <= maxRetries && !testPassed) {
|
|
62
|
+
try {
|
|
63
|
+
deepStrictEqual(
|
|
64
|
+
received,
|
|
65
|
+
expected,
|
|
66
|
+
[`Test failed for query`, query, diff(expected, received)].join(
|
|
67
|
+
"\n",
|
|
68
|
+
),
|
|
69
|
+
);
|
|
70
|
+
testPassed = true;
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if (retryCount === maxRetries) {
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
retryCount++;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
function graphql(endpoint: string, query: string) {
|
|
83
|
+
return fetch(endpoint, {
|
|
84
|
+
method: "POST",
|
|
85
|
+
headers: {
|
|
86
|
+
Accept: "application/json",
|
|
87
|
+
"Content-Type": "application/json",
|
|
88
|
+
},
|
|
89
|
+
body: JSON.stringify({ query }),
|
|
90
|
+
signal: AbortSignal.timeout(10_000),
|
|
91
|
+
}).then((response) => response.json()) as Promise<ExecutionResult>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function assert(value: unknown, message: string): asserts value {
|
|
95
|
+
if (!value) {
|
|
96
|
+
throw new Error(message);
|
|
97
|
+
}
|
|
98
|
+
}
|
package/src/testkit.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function createTest(
|
|
2
|
+
query: string,
|
|
3
|
+
expected: {
|
|
4
|
+
data?: any;
|
|
5
|
+
errors?: boolean;
|
|
6
|
+
},
|
|
7
|
+
) {
|
|
8
|
+
return {
|
|
9
|
+
query,
|
|
10
|
+
expected,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function fetchTests(endpoint: string) {
|
|
15
|
+
const response = await fetch(endpoint, {
|
|
16
|
+
method: "GET",
|
|
17
|
+
headers: {
|
|
18
|
+
Accept: "application/json",
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
if (response.status !== 200) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`Failed to fetch tests ${response.status} ${response.statusText}`,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const result = await response.json();
|
|
29
|
+
|
|
30
|
+
return result as Array<ReturnType<typeof createTest>>;
|
|
31
|
+
}
|