Skip to content

Commit cb82a82

Browse files
committed
fix(codegen): filter PostGraphile boilerplate descriptions from JSDoc output
Strip generic PostGraphile-generated descriptions that add noise: - 'The exclusive input argument for this mutation...' - 'An arbitrary string value with no semantic meaning...' - 'The output of our...' - 'All input for the...' Uses startsWith matching to handle curly apostrophe variants.
1 parent cf51978 commit cb82a82

9 files changed

Lines changed: 36 additions & 811 deletions

File tree

graphql/codegen/src/core/codegen/utils.ts

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,20 +434,46 @@ export function getQueryKeyPrefix(table: CleanTable): string {
434434
*/
435435

436436
/**
437-
* Strip PostGraphile smart comments from a description string.
437+
* PostGraphile auto-generated boilerplate descriptions that add no value.
438+
* These are generic descriptions PostGraphile puts on every mutation input,
439+
* clientMutationId field, etc. We filter them out to keep generated code clean.
440+
*/
441+
const POSTGRAPHILE_BOILERPLATE: string[] = [
442+
'The exclusive input argument for this mutation.',
443+
'An arbitrary string value with no semantic meaning.',
444+
'The output of our',
445+
'All input for the',
446+
];
447+
448+
/**
449+
* Check if a description is generic PostGraphile boilerplate that should be suppressed.
450+
*/
451+
function isBoilerplateDescription(description: string): boolean {
452+
const trimmed = description.trim();
453+
return POSTGRAPHILE_BOILERPLATE.some((bp) => trimmed.startsWith(bp));
454+
}
455+
456+
/**
457+
* Strip PostGraphile smart comments and boilerplate from a description string.
438458
*
439459
* Smart comments are lines starting with `@` (e.g., `@omit`, `@name newName`).
440-
* This returns only the human-readable portion of the comment, or undefined
441-
* if the result is empty.
460+
* Boilerplate descriptions are generic PostGraphile-generated text that repeats
461+
* on every mutation input, clientMutationId field, etc.
462+
*
463+
* This returns only the meaningful human-readable portion of the comment,
464+
* or undefined if the result is empty or boilerplate.
442465
*
443466
* @param description - Raw description from GraphQL introspection
444-
* @returns Cleaned description with smart comments removed, or undefined if empty
467+
* @returns Cleaned description, or undefined if empty/boilerplate
445468
*/
446469
export function stripSmartComments(
447470
description: string | null | undefined,
448471
): string | undefined {
449472
if (!description) return undefined;
450473

474+
// Check if entire description is boilerplate
475+
if (isBoilerplateDescription(description)) return undefined;
476+
451477
const lines = description.split('\n');
452478
const cleanLines: string[] = [];
453479

@@ -459,7 +485,12 @@ export function stripSmartComments(
459485
}
460486

461487
const result = cleanLines.join('\n').trim();
462-
return result.length > 0 ? result : undefined;
488+
if (result.length === 0) return undefined;
489+
490+
// Re-check after stripping smart comments
491+
if (isBoilerplateDescription(result)) return undefined;
492+
493+
return result;
463494
}
464495

465496
// ============================================================================

0 commit comments

Comments
 (0)