Skip to content

Commit 72a38f0

Browse files
authored
Merge pull request #784 from constructive-io/devin/1772748238-codegen-skip-prompt
feat(codegen): emit skipPrompt: true for fields with backend-managed defaults
2 parents f4176b7 + c8316c5 commit 72a38f0

136 files changed

Lines changed: 4055 additions & 7362 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

graphql/codegen/src/core/codegen/cli/table-command-generator.ts

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -536,23 +536,33 @@ function buildMutationHandler(
536536
// For create: field is required only if it has no default value
537537
// For update: all fields are optional (user only updates what they want)
538538
const isRequired = operation === 'create' && !fieldsWithDefaults.has(field.name);
539-
questions.push(
540-
t.objectExpression([
541-
t.objectProperty(t.identifier('type'), t.stringLiteral('text')),
542-
t.objectProperty(
543-
t.identifier('name'),
544-
t.stringLiteral(field.name),
545-
),
546-
t.objectProperty(
547-
t.identifier('message'),
548-
t.stringLiteral(field.name),
549-
),
539+
const hasDefault = fieldsWithDefaults.has(field.name);
540+
const questionProps = [
541+
t.objectProperty(t.identifier('type'), t.stringLiteral('text')),
542+
t.objectProperty(
543+
t.identifier('name'),
544+
t.stringLiteral(field.name),
545+
),
546+
t.objectProperty(
547+
t.identifier('message'),
548+
t.stringLiteral(field.name),
549+
),
550+
t.objectProperty(
551+
t.identifier('required'),
552+
t.booleanLiteral(isRequired),
553+
),
554+
];
555+
// Skip prompting for fields with backend-managed defaults.
556+
// The field still appears in man pages and can be overridden via CLI flags.
557+
if (hasDefault) {
558+
questionProps.push(
550559
t.objectProperty(
551-
t.identifier('required'),
552-
t.booleanLiteral(isRequired),
560+
t.identifier('skipPrompt'),
561+
t.booleanLiteral(true),
553562
),
554-
]),
555-
);
563+
);
564+
}
565+
questions.push(t.objectExpression(questionProps));
556566
}
557567
}
558568

0 commit comments

Comments
 (0)