UNPKG

@gqty/cli

Version:

Interactive codegen for GQty

6 lines (5 loc) 858 B
#! /usr/bin/env node const d=a=>a.command("generate [endpoint] [destination]",{hidden:!0}).option("--react","Create React client").description(`Inspect or read from a file a GraphQL Schema and generate the gqty client in the specified directory (./src/generated/graphql.ts by default). EXAMPLE 1: "gqty generate ./schema.gql --react" EXAMPLE 2: "gqty generate http://localhost:3000/graphql src/gqty/index.ts" EXAMPLE 3 (Configuration file): "gqty generate"`).action(async(n,c,e)=>{const{defaultConfig:i}=await import("../config.mjs"),{inspectWriteGenerate:o}=await import("../inspectWriteGenerate.mjs");let r;e.react!=null&&(r=i.react=typeof e.react=="boolean"?e.react:!!e.react);try{await o({endpoint:n,destination:c,cli:!0,generateOptions:{react:r}})}catch(t){t instanceof Error&&delete t.stack,console.error(t),process.exit(1)}});export{d as addCommand};