Repository navigation
Minor Changes
-
#347
4b1748eThanks @n1ru4l! - Add askipSatisfiabilityoption tocomposeSchemaContract. A contract only adds@inaccessibleto an already composed graph, so when the same services composed successfully without the contract, the satisfiability check cannot find anything new. Skipping it cuts roughly 45% of the time spent composing each contract.const base = composeServices(services); if (!base.errors) { const contract = composeSchemaContract(services, filter, true, { skipSatisfiability: true, }); }
The
@inaccessiblerules that contracts can trigger (for exampleREFERENCED_INACCESSIBLE,REQUIRED_INACCESSIBLEandONLY_INACCESSIBLE_CHILDREN) keep running. -
#347
4b1748eThanks @n1ru4l! - AddcomposeServicesWithContractsto compose a supergraph together with its schema contracts.Instead of composing all the subgraphs again for every contract, each contract is derived from the composed supergraph: the tag filter is applied to it, and only the rules about
@inaccessiblerun, since those are the only ones a contract can fail. The results are the same ascomposeServicesfollowed bycomposeSchemaContractfor each contract, at a fraction of the time and memory.
The document of a contract reuses the definitions it has in common with the supergraph's document, so each contract adds little memory, however many there are.const { supergraph, contracts } = composeServicesWithContracts(services, [ { filter: { include: new Set(["public"]), exclude: new Set() } }, { filter: { include: new Set(), exclude: new Set(["internal"]) }, removeUnreachableTypes: false, }, ]);
When the subgraphs fail to compose, each contract is composed from the subgraphs, as before.