/** * CLI command for mutation updateFunctionFromSource * @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 { UpdateFunctionFromSourceVariables } from '../../orm/mutation'; import type { UpdateFunctionPayloadSelect } from '../../orm/input-types'; export default async ( argv: Partial>, prompter: Inquirerer, _options: CLIOptions ) => { try { if (argv.help || argv.h) { console.log( "update-function-from-source - Replaces a `Function`'s definition from its source text; its database, schema and exposure are unchanged.\n\nUsage: update-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 .updateFunctionFromSource( parsedAnswers as unknown as UpdateFunctionFromSourceVariables, { select: selectFields, } as unknown as { select: UpdateFunctionPayloadSelect; } ) .execute(); console.log(JSON.stringify(result, null, 2)); } catch (error) { console.error('Failed: updateFunctionFromSource'); if (error instanceof Error) { console.error(error.message); } process.exit(1); } };