/** * CLI command for mutation createFunctionFromSource * @generated by @constructive-io/graphql-codegen * DO NOT EDIT - changes will be overwritten */ import { CLIOptions, Inquirerer } from 'inquirerer'; import { getClient } from '../executor'; import { unflattenDotNotation, buildSelectFromPaths } from '../utils'; import type { CreateFunctionFromSourceVariables } from '../../orm/mutation'; import type { CreateFunctionPayloadSelect } from '../../orm/input-types'; export default async ( argv: Partial>, prompter: Inquirerer, _options: CLIOptions ) => { try { if (argv.help || argv.h) { console.log( 'create-function-from-source - Creates a `Function` from its `CREATE FUNCTION` source text.\n\nUsage: create-function-from-source [OPTIONS]\n' ); process.exit(0); } const answers = await prompter.prompt(argv, [ { type: 'text', name: 'input', message: 'The exclusive input argument for this mutation. An object type, make sure to see documentation for this object\u2019s fields.', required: true, }, ]); const client = getClient(); const parsedAnswers = unflattenDotNotation(answers); const selectFields = buildSelectFromPaths((argv.select as string) ?? 'clientMutationId'); const result = await client.mutation .createFunctionFromSource( parsedAnswers as unknown as CreateFunctionFromSourceVariables, { select: selectFields, } as unknown as { select: CreateFunctionPayloadSelect; } ) .execute(); console.log(JSON.stringify(result, null, 2)); } catch (error) { console.error('Failed: createFunctionFromSource'); if (error instanceof Error) { console.error(error.message); } process.exit(1); } };