@gqty/cli
Version:
Interactive codegen for GQty
2 lines (1 loc) • 883 B
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});const PLazy=require("p-lazy");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}const PLazy__default=_interopDefaultLegacy(PLazy);function useGenerateGQty(e){const i=new PLazy__default.default((r,n)=>Promise.all([import("./writeGenerate.js"),import("./config.js").then(t=>t.loadOrGenerateConfig()),import("./config.js")]).then(([{writeGenerate:t},{config:o},{defaultConfig:a}])=>({writeGenerate:t,gqtyConfig:o,defaultConfig:a})).then(r,n));return{onSchemaChange({schema:r}){i.then(({gqtyConfig:n,writeGenerate:t,defaultConfig:o})=>{const{destination:a=n.destination??o.destination,onExistingFileConflict:s,transformsGenerate:c,onError:u=console.error,...l}=e||{};t(r,a,{...n,...l},s,c).catch(u)}).catch(e?.onError||console.error)}}}exports.useGenerateGQty=useGenerateGQty;